* Model definition for CGE model with search and matching friction
 
* Note: Steady state and transition model

* Revenue neutral variables

variables
tau_l
vlump_d
;

equations
eqn_vlump_d
eqn_rn
;

tau_l.l = tau_l0;
vlump_d.l = 0;

* Steady State Variables

parameters
p_e_ss(ind,ind2)
p_e_c_ss(ind)
;

variables
p_ss_ct(ind)
p_c_ss_ct(ind)
p_cbar_ss_ct
exch_ss_ct

sub_ss_ct(ind)

p_f_ss_ct(ind)
p_c_f_ss_ct(ind)
p_cbar_f_ss_ct

lambda_ss_ct
lambda_f_ss_ct

lambdag_ss_ct
lambdag_f_ss_ct

cbar_ss_ct
c_ss_ct(ind)
cd_ss_ct(ind)
cf_ss_ct(ind)
v_n_ss_ct(ind)
v_ng_ss_ct
phibar_ss_ct


cbar_f_ss_ct
c_f_ss_ct(ind)
cd_f_ss_ct(ind)
cf_f_ss_ct(ind)
v_n_f_ss_ct(ind)
v_ng_f_ss_ct
phibar_f_ss_ct



w_ss_ct(ind)
h_ss_ct(ind)
w_f_ss_ct(ind)
h_f_ss_ct(ind)
wg_ss_ct
hg_ss_ct
wg_f_ss_ct
hg_f_ss_ct

vbar_ss_ct(ind)
j_n_ss_ct(ind)
f_l_ss_ct(ind)
f_v_ss_ct(ind)
vv_ss_ct(ind)
io_id_ss_ct(ind,ind2)
io_if_ss_ct(ind,ind2)
cost_df_ss_ct(ind,ind2)
cost_e_ss_ct(ind)
io_ie_ss_ct(ie,ind)
cost_m_ss_ct(ind)
io_im_ss_ct(im,ind)
cost_v_ss_ct(ind)
io_ev_ss_ct(ind)
io_mv_ss_ct(ind)
iod_ss_ct(ind,ind2)
iof_ss_ct(ind,ind2)
y_ss_ct(ind)
prof_ss_ct(ind)
e_ss_ct(ind)
etot_ss_ct

vbar_f_ss_ct(ind)
j_n_f_ss_ct(ind)
f_l_f_ss_ct(ind)
f_v_f_ss_ct(ind)
l_f_ss_ct(ind)
vv_f_ss_ct(ind)
io_id_f_ss_ct(ind,ind2)
io_if_f_ss_ct(ind,ind2)
cost_df_f_ss_ct(ind,ind2)
cost_e_f_ss_ct(ind)
io_ie_f_ss_ct(ie,ind)
cost_m_f_ss_ct(ind)
io_im_f_ss_ct(im,ind)
cost_v_f_ss_ct(ind)
io_ev_f_ss_ct(ind)
io_mv_f_ss_ct(ind)
iod_f_ss_ct(ind,ind2)
iof_f_ss_ct(ind,ind2)
y_f_ss_ct(ind)
prof_f_ss_ct(ind)


vbarg_ss_ct
cg_n_ss_ct
f_lg_ss_ct
f_vg_ss_ct
vvg_ss_ct
io_idg_ss_ct(ind)
io_ifg_ss_ct(ind)
cost_dfg_ss_ct(ind)
cost_eg_ss_ct
io_ieg_ss_ct(ie)
cost_mg_ss_ct
io_img_ss_ct(im)
cost_vg_ss_ct
io_evg_ss_ct
io_mvg_ss_ct
gd_ss_ct
gf_ss_ct


vbarg_f_ss_ct
cg_n_f_ss_ct
f_lg_f_ss_ct
f_vg_f_ss_ct
vvg_f_ss_ct
io_idg_f_ss_ct(ind)
io_ifg_f_ss_ct(ind)
cost_dfg_f_ss_ct(ind)
cost_eg_f_ss_ct
io_ieg_f_ss_ct(ie)
cost_mg_f_ss_ct
io_img_f_ss_ct(im)
cost_vg_f_ss_ct
io_evg_f_ss_ct
io_mvg_f_ss_ct
gd_f_ss_ct
gf_f_ss_ct


phi_i_ss_ct(ind)
q_ss_ct(ind)
theta_i_ss_ct(ind)
n_ss_ct(ind)

phi_g_ss_ct
qg_ss_ct
theta_g_ss_ct
ng_ss_ct

thetatot_ss_ct
ntot_ss_ct

phi_f_ss_ct(ind)
q_f_ss_ct(ind)
theta_f_ss_ct(ind)
n_f_ss_ct(ind)

phig_f_ss_ct
qg_f_ss_ct
thetag_f_ss_ct
ng_f_ss_ct


thetatot_f_ss_ct
ntot_f_ss_ct

grev_ss_ct
tlump_ss_ct
vlump_ss_ct


grev_f_ss_ct
tlump_f_ss_ct

exports_ss_ct(ind)
imports_ss_ct(ind)

;



equations
eqn_p_cbar_ss_ct
eqn_p_c_ss_ct(ind)


eqn_p_cbar_f_ss_ct
eqn_p_c_f_ss_ct(ind)

eqn_hhfoc_ss_ct
eqn_bc_ss_ct
eqn_c_ss_ct(ind)
eqn_cd_ss_ct(ind)
eqn_cf_ss_ct(ind)

eqn_v_n_ss_ct(ind)
eqn_v_ng_ss_ct
eqn_phibar_ss_ct

eqn_hhfoc_f_ss_ct
eqn_bc_f_ss_ct
eqn_c_f_ss_ct(ind)
eqn_cd_f_ss_ct(ind)
eqn_cf_f_ss_ct(ind)

eqn_v_n_f_ss_ct(ind)
eqn_v_ng_f_ss_ct
eqn_phibar_f_ss_ct


eqn_nash_ss_ct(ind)
eqn_intra_ss_ct(ind)

eqn_nash_f_ss_ct(ind)
eqn_intra_f_ss_ct(ind)

eqn_nashg_ss_ct
eqn_intrag_ss_ct

eqn_nashg_f_ss_ct
eqn_intrag_f_ss_ct


eqn_foc_vbar_ss_ct(ind)
eqn_foc_v_ss_ct(ind)
eqn_foc_n_ss_ct(ind)
eqn_f_l_ss_ct(ind)
eqn_f_v_ss_ct(ind)
eqn_cost_df_ss_ct(ind,ind2)
eqn_io_id_ss_ct(ind,ind2)
eqn_io_if_ss_ct(ind,ind2)
eqn_cost_e_ss_ct(ind)
eqn_io_ie_ss_ct(ie,ind)
eqn_cost_m_ss_ct(ind)
eqn_io_im_ss_ct(im,ind)
eqn_cost_v_ss_ct(ind)
eqn_io_ev_ss_ct(ind)
eqn_io_mv_ss_ct(ind)
eqn_firm_iod_e_ss_ct(ie,ind)
eqn_firm_iod_m_ss_ct(im,ind)
eqn_firm_iof_e_ss_ct(ie,ind)
eqn_firm_iof_m_ss_ct(im,ind)
eqn_y_ss_ct(ind)
eqn_prof_ss_ct(ind)
eqn_e_ss_ct(ind)
eqn_etot_ss_ct


eqn_foc_vbar_f_ss_ct(ind)
eqn_foc_v_f_ss_ct(ind)
eqn_foc_n_f_ss_ct(ind)
eqn_f_l_f_ss_ct(ind)
eqn_f_v_f_ss_ct(ind)
eqn_cost_df_f_ss_ct(ind,ind2)
eqn_io_id_f_ss_ct(ind,ind2)
eqn_io_if_f_ss_ct(ind,ind2)
eqn_cost_e_f_ss_ct(ind)
eqn_io_ie_f_ss_ct(ie,ind)
eqn_cost_m_f_ss_ct(ind)
eqn_io_im_f_ss_ct(im,ind)
eqn_cost_v_f_ss_ct(ind)
eqn_io_ev_f_ss_ct(ind)
eqn_io_mv_f_ss_ct(ind)
eqn_firm_iod_e_f_ss_ct(ie,ind)
eqn_firm_iod_m_f_ss_ct(im,ind)
eqn_firm_iof_e_f_ss_ct(ie,ind)
eqn_firm_iof_m_f_ss_ct(im,ind)
eqn_y_f_ss_ct(ind)
eqn_prof_f_ss_ct(ind)

eqn_foc_vbarg_ss_ct
eqn_foc_vg_ss_ct
eqn_foc_ng_ss_ct
eqn_f_lg_ss_ct
eqn_f_vg_ss_ct
eqn_cost_dfg_ss_ct
eqn_io_idg_ss_ct
eqn_io_ifg_ss_ct
eqn_cost_eg_ss_ct
eqn_io_ieg_ss_ct(ie)
eqn_cost_mg_ss_ct
eqn_io_img_ss_ct(im)
eqn_cost_vg_ss_ct
eqn_io_evg_ss_ct
eqn_io_mvg_ss_ct
eqn_gd_e_ss_ct
eqn_gd_m_ss_ct
eqn_gf_e_ss_ct
eqn_gf_m_ss_ct

eqn_foc_vbarg_f_ss_ct
eqn_foc_vg_f_ss_ct
eqn_foc_ng_f_ss_ct
eqn_f_lg_f_ss_ct
eqn_f_vg_f_ss_ct
eqn_cost_dfg_f_ss_ct
eqn_io_idg_f_ss_ct
eqn_io_ifg_f_ss_ct
eqn_cost_eg_f_ss_ct
eqn_io_ieg_f_ss_ct(ie)
eqn_cost_mg_f_ss_ct
eqn_io_img_f_ss_ct(im)
eqn_cost_vg_f_ss_ct
eqn_io_evg_f_ss_ct
eqn_io_mvg_f_ss_ct
eqn_gd_f_e_ss_ct
eqn_gd_f_m_ss_ct
eqn_gf_f_e_ss_ct
eqn_gf_f_m_ss_ct


eqn_phi_i_ss_ct(ind)
eqn_q_ss_ct(ind)
eqn_theta_i_ss_ct(ind)
eqn_n_ss_ct(ind)

eqn_phi_g_ss_ct
eqn_qg_ss_ct
eqn_theta_g_ss_ct
eqn_ng_ss_ct

eqn_thetatot_ss_ct
eqn_ntot_ss_ct

eqn_phi_f_ss_ct(ind)
eqn_q_f_ss_ct(ind)
eqn_theta_f_ss_ct(ind)
eqn_n_f_ss_ct(ind)

eqn_phig_f_ss_ct
eqn_qg_f_ss_ct
eqn_thetag_f_ss_ct
eqn_ng_f_ss_ct


eqn_thetatot_f_ss_ct
eqn_ntot_f_ss_ct

eqn_sub_ss_ct

eqn_grev_ss_ct
eqn_tlump_ss_ct
eqn_vlump_ss_ct

eqn_grev_f_ss_ct
eqn_tlump_f_ss_ct

eqn_exports_ss_ct(ind)
eqn_imports_ss_ct(ind)
eqn_tbal_ss_ct

eqn_mc_ss_ct(ind)
eqn_mc_f_ss_ct(ind)
eqn_yg_ss_ct
eqn_yg_f_ss_ct
;

** Aggregate Prices

eqn_p_cbar_ss_ct.. p_cbar_ss_ct =e= gammac**(sigmac/(1-sigmac))*(sum(ind,(alphac(ind)**sigmac)*p_c_ss_ct(ind)**(1-sigmac)))**(1/(1-sigmac));
eqn_p_c_ss_ct(ind).. p_c_ss_ct(ind) =e= gammacf(ind)**(sig_c(ind)/(1-sig_c(ind)))*( (alphac_d(ind)**sig_c(ind))*((p_ss_ct(ind))**(1-sig_c(ind))) + (alphac_f(ind)**sig_c(ind))*(((p_f_ss_ct(ind)/exch_ss_ct)+tar_i2(ind)*p_e_c_ss(ind))**(1-sig_c(ind))) )**(1/(1-sig_c(ind)));

eqn_p_cbar_f_ss_ct.. p_cbar_f_ss_ct =e= gammac_ff**(sigmac/(1-sigmac))*(sum(ind,(alphac_ff(ind)**sigmac)*p_c_f_ss_ct(ind)**(1-sigmac)))**(1/(1-sigmac));
eqn_p_c_f_ss_ct(ind).. p_c_f_ss_ct(ind) =e= gammacf_f(ind)**(sig_c_f(ind)/(1-sig_c_f(ind)))*( (alphac_d_f(ind)**sig_c_f(ind))*((p_f_ss_ct(ind))**(1-sig_c_f(ind))) + (alphac_f_f(ind)**sig_c_f(ind))*(((p_ss_ct(ind)*exch_ss_ct) )**(1-sig_c_f(ind))) )**(1/(1-sig_c_f(ind)));

** Household


eqn_hhfoc_ss_ct.. cbar_ss_ct**(-sigma) =e= p_cbar_ss_ct*lambda_ss_ct;
eqn_bc_ss_ct.. (1-tau_l)*(sum(ind,n_ss_ct(ind)*w_ss_ct(ind)*h_ss_ct(ind)) + ng_ss_ct*wg_ss_ct*hg_ss_ct) + (1-ntot_ss_ct)*p_cbar_ss_ct*b0.l + p_cbar_ss_ct*tlump_ss_ct  + sum(ind,prof_ss_ct(ind))  - p_cbar_ss_ct*cbar_ss_ct =g= 0;
eqn_c_ss_ct(ind).. c_ss_ct(ind) =e= ((gammac*alphac(ind))**sigmac)*((p_cbar_ss_ct/p_c_ss_ct(ind))**sigmac)*cbar_ss_ct;
eqn_cd_ss_ct(ind).. cd_ss_ct(ind) =e= ((gammacf(ind)*alphac_d(ind))**sig_c(ind))*((p_c_ss_ct(ind)/p_ss_ct(ind))**sig_c(ind))*c_ss_ct(ind);
eqn_cf_ss_ct(ind).. cf_ss_ct(ind) =e= ((gammacf(ind)*alphac_f(ind))**sig_c(ind))*((p_c_ss_ct(ind)/((p_f_ss_ct(ind)/exch_ss_ct)+tar_i2(ind)*p_e_c_ss(ind)))**sig_c(ind))*c_ss_ct(ind);

eqn_v_n_ss_ct(ind).. v_n_ss_ct(ind) =e= ((1-tau)/tau)*((1-tau_l)/(1+tau_p0))*lambda_ss_ct*j_n_ss_ct(ind);
eqn_v_ng_ss_ct.. v_ng_ss_ct =e= ((1-tau)/tau)*((1-tau_l)/(1+tau_p0))*lambda_ss_ct*(-cg_n_ss_ct);
eqn_phibar_ss_ct.. phibar_ss_ct =e= beta*sum(ind,phi_i_ss_ct(ind)*v_n_ss_ct(ind)) + beta*phi_g_ss_ct*v_ng_ss_ct;

eqn_hhfoc_f_ss_ct.. (cbar_f_ss_ct/ratiof)**(-sigma) =e= p_cbar_f_ss_ct*lambda_f_ss_ct;
eqn_bc_f_ss_ct.. (1-tau_l0)*(sum(ind,n_f_ss_ct(ind)*w_f_ss_ct(ind)*h_f_ss_ct(ind)) + ng_f_ss_ct*wg_f_ss_ct*hg_f_ss_ct) + (ratiof-ntot_f_ss_ct)*p_cbar_f_ss_ct*b0_f.l + p_cbar_f_ss_ct*tlump_f_ss_ct  + sum(ind,prof_f_ss_ct(ind))  - p_cbar_f_ss_ct*cbar_f_ss_ct =g= 0;
eqn_c_f_ss_ct(ind).. c_f_ss_ct(ind) =e= ((gammac_ff*alphac_ff(ind))**sigmac)*((p_cbar_f_ss_ct/p_c_f_ss_ct(ind))**sigmac)*cbar_f_ss_ct;
eqn_cd_f_ss_ct(ind).. cd_f_ss_ct(ind) =e= ((gammacf_f(ind)*alphac_d_f(ind))**sig_c_f(ind))*((p_c_f_ss_ct(ind)/p_f_ss_ct(ind))**sig_c_f(ind))*c_f_ss_ct(ind);
eqn_cf_f_ss_ct(ind).. cf_f_ss_ct(ind) =e= ((gammacf_f(ind)*alphac_f_f(ind))**sig_c_f(ind))*((p_c_f_ss_ct(ind)/((p_ss_ct(ind)*exch_ss_ct)))**sig_c_f(ind))*c_f_ss_ct(ind);


eqn_v_n_f_ss_ct(ind).. v_n_f_ss_ct(ind) =e= ((1-tau)/tau)*((1-tau_l0)/(1+tau_p0))*lambda_f_ss_ct*j_n_f_ss_ct(ind);
eqn_v_ng_f_ss_ct.. v_ng_f_ss_ct =e= ((1-tau)/tau)*((1-tau_l0)/(1+tau_p0))*lambda_f_ss_ct*(-cg_n_f_ss_ct);
eqn_phibar_f_ss_ct.. phibar_f_ss_ct =e= beta*sum(ind,phi_f_ss_ct(ind)*v_n_f_ss_ct(ind)) + beta*phig_f_ss_ct*v_ng_f_ss_ct;

** Nash Bargaining


eqn_nash_ss_ct(ind).. (1-tau_l)*w_ss_ct(ind)*h_ss_ct(ind) =e= ((1-tau_l)/(1+tau_p0))*(1-tau)*( f_l_ss_ct(ind)*h_ss_ct(ind)*(p_ss_ct(ind)*(1+sub_ss_ct(ind)))  )
 + tau*((psi.l*(h_ss_ct(ind)**(1+chi))/(1+chi))/lambda_ss_ct + b0.l*p_cbar_ss_ct + phibar_ss_ct/lambda_ss_ct);

eqn_intra_ss_ct(ind).. (1-tau_l)*lambda_ss_ct*(f_l_ss_ct(ind)*p_ss_ct(ind)*(1+sub_ss_ct(ind))) =e= (1+tau_p0)*psi.l*(h_ss_ct(ind)**chi);

eqn_nash_f_ss_ct(ind).. (1-tau_l0)*w_f_ss_ct(ind)*h_f_ss_ct(ind) =e= ((1-tau_l0)/(1+tau_p0))*(1-tau)*( f_l_f_ss_ct(ind)*h_f_ss_ct(ind)*(p_f_ss_ct(ind)) + sum(ind2,(f_l_f_ss_ct(ind2)*p_f_ss_ct(ind2))*theta_f_ss_ct(ind2)) + lambdag_f_ss_ct*f_lg_f_ss_ct*thetag_f_ss_ct )
 + tau*((psi_f.l*(h_f_ss_ct(ind)**(1+chi))/(1+chi))/lambda_f_ss_ct + b0_f.l*p_cbar_f_ss_ct);

eqn_intra_f_ss_ct(ind).. (1-tau_l0)*lambda_f_ss_ct*(f_l_f_ss_ct(ind)*p_f_ss_ct(ind)) =e= (1+tau_p0)*psi_f.l*(h_f_ss_ct(ind)**chi);




eqn_nashg_ss_ct.. (1-tau_l)*wg_ss_ct*hg_ss_ct =e= ((1-tau_l)/(1+tau_p0))*(1-tau)*( f_lg_ss_ct*hg_ss_ct*(lambdag_ss_ct)  )
 + tau*((psi.l*(hg_ss_ct**(1+chi))/(1+chi))/lambda_ss_ct + b0.l*p_cbar_ss_ct  + phibar_ss_ct/lambda_ss_ct);

eqn_intrag_ss_ct.. (1-tau_l)*lambda_ss_ct*(f_lg_ss_ct*lambdag_ss_ct) =e= (1+tau_p0)*psi.l*(hg_ss_ct**chi);

eqn_nashg_f_ss_ct.. (1-tau_l0)*wg_f_ss_ct*hg_f_ss_ct =e= ((1-tau_l0)/(1+tau_p0))*(1-tau)*( f_lg_f_ss_ct*hg_f_ss_ct*(lambdag_f_ss_ct) + sum(ind2,(f_l_f_ss_ct(ind2)*p_f_ss_ct(ind2))*theta_f_ss_ct(ind2)) + lambdag_f_ss_ct*f_lg_f_ss_ct*thetag_f_ss_ct )
 + tau*((psi_f.l*(hg_f_ss_ct**(1+chi))/(1+chi))/lambda_f_ss_ct + b0_f.l*p_cbar_f_ss_ct);

eqn_intrag_f_ss_ct.. (1-tau_l0)*lambda_f_ss_ct*(f_lg_f_ss_ct*lambdag_f_ss_ct) =e= (1+tau_p0)*psi_f.l*(hg_f_ss_ct**chi);

** Firm

* First-order conditions for recruitment and intermediate inputs

eqn_foc_vbar_ss_ct(ind).. q_ss_ct(ind) =e= ((p_ss_ct(ind)*(1+sub_ss_ct(ind)))*f_l_ss_ct(ind))/(beta*j_n_ss_ct(ind));
eqn_foc_v_ss_ct(ind).. f_v_ss_ct(ind) =e= cost_v_ss_ct(ind)/(p_ss_ct(ind)*(1+sub_ss_ct(ind)));
eqn_foc_n_ss_ct(ind).. f_l_ss_ct(ind) =e= ((1-beta*(1-pi(ind)))*j_n_ss_ct(ind) + (1+tau_p0)*w_ss_ct(ind)*h_ss_ct(ind))/((p_ss_ct(ind)*(1+sub_ss_ct(ind)))*h_ss_ct(ind));
eqn_f_l_ss_ct(ind).. f_l_ss_ct(ind) =e= alphap.l(ind)*gammay_ss_ct(ind)*( alphap.l(ind)* (h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**rho(ind) + (1-alphap.l(ind))*vv_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*(h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**(rho(ind)-1);
eqn_f_v_ss_ct(ind).. f_v_ss_ct(ind) =e= (1-alphap.l(ind))*gammay_ss_ct(ind)*( alphap.l(ind)* (h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**rho(ind) + (1-alphap.l(ind))*vv_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*vv_ss_ct(ind)**(rho(ind)-1);


eqn_foc_vbar_f_ss_ct(ind).. q_f_ss_ct(ind) =e= ((p_f_ss_ct(ind))*f_l_f_ss_ct(ind))/(beta*j_n_f_ss_ct(ind));
eqn_foc_v_f_ss_ct(ind).. f_v_f_ss_ct(ind) =e= cost_v_f_ss_ct(ind)/(p_f_ss_ct(ind));
eqn_foc_n_f_ss_ct(ind).. f_l_f_ss_ct(ind) =e= ((1-beta*(1-pi(ind)))*j_n_f_ss_ct(ind) + (1+tau_p0)*w_f_ss_ct(ind)*h_f_ss_ct(ind))/((p_f_ss_ct(ind))*h_f_ss_ct(ind));
eqn_f_l_f_ss_ct(ind).. f_l_f_ss_ct(ind) =e= alphap_f.l(ind)*gammay0_f.l(ind)*( alphap_f.l(ind)* (h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**rho(ind) + (1-alphap_f.l(ind))*vv_f_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*(h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**(rho(ind)-1);
eqn_f_v_f_ss_ct(ind).. f_v_f_ss_ct(ind) =e= (1-alphap_f.l(ind))*gammay0_f.l(ind)*( alphap_f.l(ind)* (h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**rho(ind) + (1-alphap_f.l(ind))*vv_f_ss_ct(ind)**rho(ind) )**(1/rho(ind)-1)*(vv_f_ss_ct(ind))**(rho(ind)-1);


* Intermediate input demand

eqn_cost_df_ss_ct(ind,ind2).. cost_df_ss_ct(ind,ind2) =e= gammadf(ind,ind2)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadf_d(ind,ind2)**sig_df(ind))*((p_ss_ct(ind)+mu_e(ind,ind2)*p_e_ss(ind,ind2))**(1-sig_df(ind))) + (alphadf_f(ind,ind2)**sig_df(ind))*(((p_f_ss_ct(ind)/exch_ss_ct)+mu_e(ind,ind2)*p_e_ss(ind,ind2)+tar_i2(ind)*p_e_ss(ind,ind2))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_id_ss_ct(ind,ind2).. io_id_ss_ct(ind,ind2) =e= ((gammadf(ind,ind2)*alphadf_d(ind,ind2))**sig_df(ind)) * ((p_ss_ct(ind)+mu_e(ind,ind2)*p_e_ss(ind,ind2))/cost_df_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_io_if_ss_ct(ind,ind2).. io_if_ss_ct(ind,ind2)  =e=  ((gammadf(ind,ind2)*alphadf_f(ind,ind2))**sig_df(ind)) * (((p_f_ss_ct(ind)/exch_ss_ct)+mu_e(ind,ind2)*p_e_ss(ind,ind2)+tar_i2(ind)*p_e_ss(ind,ind2))/cost_df_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_cost_e_ss_ct(ind).. cost_e_ss_ct(ind) =e= gammae(ind)**(sig_e(ind)/(1-sig_e(ind)))*( sum(ie, (alphae(ie,ind)**sig_e(ind))*(cost_df_ss_ct(ie,ind))**(1-sig_e(ind))) )**(1/(1-sig_e(ind)));
eqn_io_ie_ss_ct(ie,ind).. io_ie_ss_ct(ie,ind) =e= ((gammae(ind)*alphae(ie,ind))**sig_e(ind)) * (cost_df_ss_ct(ie,ind)/cost_e_ss_ct(ind))**(-sig_e(ind));
eqn_cost_m_ss_ct(ind).. cost_m_ss_ct(ind) =e= gammam(ind)**(sig_m(ind)/(1-sig_m(ind)))*( sum(im, (alpham(im,ind)**sig_m(ind))*(cost_df_ss_ct(im,ind))**(1-sig_m(ind))) )**(1/(1-sig_m(ind)));
eqn_io_im_ss_ct(im,ind).. io_im_ss_ct(im,ind) =e= ((gammam(ind)*alpham(im,ind))**sig_m(ind)) * (cost_df_ss_ct(im,ind)/cost_m_ss_ct(ind))**(-sig_m(ind));
eqn_cost_v_ss_ct(ind).. cost_v_ss_ct(ind) =e= gammav_ss(ind)**(sig_v(ind)/(1-sig_v(ind)))*( (alphav_e(ind)**sig_v(ind))*((cost_e_ss_ct(ind))**(1-sig_v(ind))) + (alphav_m(ind)**sig_v(ind))*((cost_m_ss_ct(ind))**(1-sig_v(ind))) )**(1/(1-sig_v(ind)));
eqn_io_ev_ss_ct(ind).. io_ev_ss_ct(ind) =e= ((gammav_ss(ind)*alphav_e(ind))**sig_v(ind)) * (cost_e_ss_ct(ind)/cost_v_ss_ct(ind))**(-sig_v(ind));
eqn_io_mv_ss_ct(ind).. io_mv_ss_ct(ind) =e= ((gammav_ss(ind)*alphav_m(ind))**sig_v(ind)) * (cost_m_ss_ct(ind)/cost_v_ss_ct(ind))**(-sig_v(ind));
eqn_firm_iod_e_ss_ct(ie,ind).. iod_ss_ct(ie,ind) =e= io_id_ss_ct(ie,ind)*io_ie_ss_ct(ie,ind)*io_ev_ss_ct(ind)*vv_ss_ct(ind);
eqn_firm_iod_m_ss_ct(im,ind).. iod_ss_ct(im,ind) =e= io_id_ss_ct(im,ind)*io_im_ss_ct(im,ind)*io_mv_ss_ct(ind)*vv_ss_ct(ind);
eqn_firm_iof_e_ss_ct(ie,ind).. iof_ss_ct(ie,ind) =e= io_if_ss_ct(ie,ind)*io_ie_ss_ct(ie,ind)*io_ev_ss_ct(ind)*vv_ss_ct(ind);
eqn_firm_iof_m_ss_ct(im,ind).. iof_ss_ct(im,ind) =e= io_if_ss_ct(im,ind)*io_im_ss_ct(im,ind)*io_mv_ss_ct(ind)*vv_ss_ct(ind);


eqn_cost_df_f_ss_ct(ind,ind2).. cost_df_f_ss_ct(ind,ind2) =e= gammadf_f(ind,ind2)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadf_d_f(ind,ind2)**sig_df(ind))*((p_f_ss_ct(ind))**(1-sig_df(ind))) + (alphadf_f_f(ind,ind2)**sig_df(ind))*(((p_ss_ct(ind)*exch_ss_ct))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_id_f_ss_ct(ind,ind2).. io_id_f_ss_ct(ind,ind2) =e= ((gammadf_f(ind,ind2)*alphadf_d_f(ind,ind2))**sig_df(ind)) * ((p_f_ss_ct(ind))/cost_df_f_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_io_if_f_ss_ct(ind,ind2).. io_if_f_ss_ct(ind,ind2)  =e=  ((gammadf_f(ind,ind2)*alphadf_f_f(ind,ind2))**sig_df(ind)) * (((p_ss_ct(ind)*exch_ss_ct))/cost_df_f_ss_ct(ind,ind2))**(-sig_df(ind));
eqn_cost_e_f_ss_ct(ind).. cost_e_f_ss_ct(ind) =e= gammae_f(ind)**(sig_e(ind)/(1-sig_e(ind)))*( sum(ie, (alphae_f(ie,ind)**sig_e(ind))*(cost_df_f_ss_ct(ie,ind))**(1-sig_e(ind))) )**(1/(1-sig_e(ind)));
eqn_io_ie_f_ss_ct(ie,ind).. io_ie_f_ss_ct(ie,ind) =e= ((gammae_f(ind)*alphae_f(ie,ind))**sig_e(ind)) * (cost_df_f_ss_ct(ie,ind)/cost_e_f_ss_ct(ind))**(-sig_e(ind));
eqn_cost_m_f_ss_ct(ind).. cost_m_f_ss_ct(ind) =e= gammam_f(ind)**(sig_m(ind)/(1-sig_m(ind)))*( sum(im, (alpham_f(im,ind)**sig_m(ind))*(cost_df_f_ss_ct(im,ind))**(1-sig_m(ind))) )**(1/(1-sig_m(ind)));
eqn_io_im_f_ss_ct(im,ind).. io_im_f_ss_ct(im,ind) =e= ((gammam_f(ind)*alpham_f(im,ind))**sig_m(ind)) * (cost_df_f_ss_ct(im,ind)/cost_m_f_ss_ct(ind))**(-sig_m(ind));
eqn_cost_v_f_ss_ct(ind).. cost_v_f_ss_ct(ind) =e= gammav_f(ind)**(sig_v(ind)/(1-sig_v(ind)))*( (alphav_e_f(ind)**sig_v(ind))*((cost_e_f_ss_ct(ind))**(1-sig_v(ind))) + (alphav_m_f(ind)**sig_v(ind))*((cost_m_f_ss_ct(ind))**(1-sig_v(ind))) )**(1/(1-sig_v(ind)));
eqn_io_ev_f_ss_ct(ind).. io_ev_f_ss_ct(ind) =e= ((gammav_f(ind)*alphav_e_f(ind))**sig_v(ind)) * (cost_e_f_ss_ct(ind)/cost_v_f_ss_ct(ind))**(-sig_v(ind));
eqn_io_mv_f_ss_ct(ind).. io_mv_f_ss_ct(ind) =e= ((gammav_f(ind)*alphav_m_f(ind))**sig_v(ind)) * (cost_m_f_ss_ct(ind)/cost_v_f_ss_ct(ind))**(-sig_v(ind));
eqn_firm_iod_e_f_ss_ct(ie,ind).. iod_f_ss_ct(ie,ind) =e= io_id_f_ss_ct(ie,ind)*io_ie_f_ss_ct(ie,ind)*io_ev_f_ss_ct(ind)*vv_f_ss_ct(ind);
eqn_firm_iod_m_f_ss_ct(im,ind).. iod_f_ss_ct(im,ind) =e= io_id_f_ss_ct(im,ind)*io_im_f_ss_ct(im,ind)*io_mv_f_ss_ct(ind)*vv_f_ss_ct(ind);
eqn_firm_iof_e_f_ss_ct(ie,ind).. iof_f_ss_ct(ie,ind) =e= io_if_f_ss_ct(ie,ind)*io_ie_f_ss_ct(ie,ind)*io_ev_f_ss_ct(ind)*vv_f_ss_ct(ind);
eqn_firm_iof_m_f_ss_ct(im,ind).. iof_f_ss_ct(im,ind) =e= io_if_f_ss_ct(im,ind)*io_im_f_ss_ct(im,ind)*io_mv_f_ss_ct(ind)*vv_f_ss_ct(ind);

* Output and profits
eqn_y_ss_ct(ind).. y_ss_ct(ind) =e= gammay_ss_ct(ind)*(alphap.l(ind)*(h_ss_ct(ind)*n_ss_ct(ind)*(1-vbar_ss_ct(ind)))**rho(ind) + (1-alphap.l(ind))*vv_ss_ct(ind)**rho(ind))**(1/rho(ind));
eqn_prof_ss_ct(ind).. prof_ss_ct(ind) =e= (p_ss_ct(ind)*(1+sub_ss_ct(ind)))*y_ss_ct(ind) - (1+tau_p0)*w_ss_ct(ind)*n_ss_ct(ind)*h_ss_ct(ind) - cost_v_ss_ct(ind)*vv_ss_ct(ind) ;
eqn_e_ss_ct(ind).. e_ss_ct(ind) =e=  sum(ie,mu_e(ie,ind)*(iod_ss_ct(ie,ind)+iof_ss_ct(ie,ind))) + sum(secondary,sum(oilgas,mu_e(oilgas,secondary))*f_y0(secondary)*iof_ss_ct(secondary,ind));
eqn_etot_ss_ct.. etot_ss_ct =e= sum(ind,e_ss_ct(ind)) - sum(oilgas,sum(secondary,((iod_ss_ct(oilgas,secondary)+iof_ss_ct(oilgas,secondary))/y_ss_ct(secondary))*mu_e(oilgas,secondary)*exports_ss_ct(secondary))) + sum(oilgas,sum(secondary,f_y0(secondary)*mu_e(oilgas,secondary)*(cf_ss_ct(secondary)+gf_ss_ct(secondary))));

eqn_y_f_ss_ct(ind).. y_f_ss_ct(ind) =e= gammay0_f.l(ind)*(alphap_f.l(ind)*(h_f_ss_ct(ind)*n_f_ss_ct(ind)*(1-vbar_f_ss_ct(ind)))**rho(ind) + (1-alphap_f.l(ind))*vv_f_ss_ct(ind)**rho(ind))**(1/rho(ind));
eqn_prof_f_ss_ct(ind).. prof_f_ss_ct(ind) =e= (p_f_ss_ct(ind))*y_f_ss_ct(ind) - (1+tau_p0)*w_f_ss_ct(ind)*n_f_ss_ct(ind)*h_f_ss_ct(ind) - cost_v_f_ss_ct(ind)*vv_f_ss_ct(ind) ;


** Government

eqn_foc_vbarg_ss_ct.. qg_ss_ct =e= ((lambdag_ss_ct)*f_lg_ss_ct)/(beta*(-cg_n_ss_ct));
eqn_foc_vg_ss_ct.. lambdag_ss_ct*f_vg_ss_ct =e=  cost_vg_ss_ct;
eqn_foc_ng_ss_ct.. f_lg_ss_ct =e= ((beta*(1-pig)-1)*cg_n_ss_ct + (1+tau_p0)*wg_ss_ct*hg_ss_ct)/(lambdag_ss_ct*hg_ss_ct);
eqn_f_lg_ss_ct.. f_lg_ss_ct =e= alphapg.l*gammayg0.l*( alphapg.l* (hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**rhog + (1-alphapg.l)*vvg_ss_ct**rhog )**(1/rhog-1)*(hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**(rhog-1);
eqn_f_vg_ss_ct.. f_vg_ss_ct =e= (1-alphapg.l)*gammayg0.l*( alphapg.l* (hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**rhog + (1-alphapg.l)*vvg_ss_ct**rhog )**(1/rhog-1)*(vvg_ss_ct)**(rhog-1);

eqn_cost_dfg_ss_ct(ind).. cost_dfg_ss_ct(ind) =e= gammadfg(ind)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadfg_d(ind)**sig_df(ind))*((p_ss_ct(ind))**(1-sig_df(ind))) + (alphadfg_f(ind)**sig_df(ind))*(((p_f_ss_ct(ind)/exch_ss_ct))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_idg_ss_ct(ind).. io_idg_ss_ct(ind) =e= ((gammadfg(ind)*alphadfg_d(ind))**sig_df(ind)) * ((p_ss_ct(ind))/cost_dfg_ss_ct(ind))**(-sig_df(ind));
eqn_io_ifg_ss_ct(ind).. io_ifg_ss_ct(ind)  =e=  ((gammadfg(ind)*alphadfg_f(ind))**sig_df(ind)) * (((p_f_ss_ct(ind)/exch_ss_ct))/cost_dfg_ss_ct(ind))**(-sig_df(ind));
eqn_cost_eg_ss_ct.. cost_eg_ss_ct =e= gammaeg**(sig_eg/(1-sig_eg))*( sum(ie, (alphaeg(ie)**sig_eg)*(cost_dfg_ss_ct(ie))**(1-sig_eg)) )**(1/(1-sig_eg));
eqn_io_ieg_ss_ct(ie).. io_ieg_ss_ct(ie) =e= ((gammaeg*alphaeg(ie))**sig_eg) * ((cost_dfg_ss_ct(ie))/cost_eg_ss_ct)**(-sig_eg);
eqn_cost_mg_ss_ct.. cost_mg_ss_ct =e= gammamg**(sig_mg/(1-sig_mg))*( sum(im, (alphamg(im)**sig_mg)*(cost_dfg_ss_ct(im))**(1-sig_mg)) )**(1/(1-sig_mg));
eqn_io_img_ss_ct(im).. io_img_ss_ct(im) =e= ((gammamg*alphamg(im))**sig_mg) * (cost_dfg_ss_ct(im)/cost_mg_ss_ct)**(-sig_mg);
eqn_cost_vg_ss_ct.. cost_vg_ss_ct =e= gammavg**(sig_vg/(1-sig_vg))*( (alphavg_e**sig_vg)*((cost_eg_ss_ct)**(1-sig_vg)) + (alphavg_m**sig_vg)*((cost_mg_ss_ct)**(1-sig_vg)) )**(1/(1-sig_vg));
eqn_io_evg_ss_ct.. io_evg_ss_ct =e= ((gammavg*alphavg_e)**sig_vg) * (cost_eg_ss_ct/cost_vg_ss_ct)**(-sig_vg);
eqn_io_mvg_ss_ct.. io_mvg_ss_ct =e= ((gammavg*alphavg_m)**sig_vg) * (cost_mg_ss_ct/cost_vg_ss_ct)**(-sig_vg);
eqn_gd_e_ss_ct(ie).. gd_ss_ct(ie) =e= vvg_ss_ct*io_evg_ss_ct*io_ieg_ss_ct(ie)*io_idg_ss_ct(ie);
eqn_gd_m_ss_ct(im).. gd_ss_ct(im) =e= vvg_ss_ct*io_mvg_ss_ct*io_img_ss_ct(im)*io_idg_ss_ct(im);
eqn_gf_e_ss_ct(ie).. gf_ss_ct(ie) =e= vvg_ss_ct*io_evg_ss_ct*io_ieg_ss_ct(ie)*io_ifg_ss_ct(ie);
eqn_gf_m_ss_ct(im).. gf_ss_ct(im) =e= vvg_ss_ct*io_mvg_ss_ct*io_img_ss_ct(im)*io_ifg_ss_ct(im);

eqn_foc_vbarg_f_ss_ct.. qg_f_ss_ct =e= ((lambdag_f_ss_ct)*f_lg_f_ss_ct)/(beta*(-cg_n_f_ss_ct));
eqn_foc_vg_f_ss_ct.. lambdag_f_ss_ct*f_vg_f_ss_ct =e=  cost_vg_f_ss_ct;
eqn_foc_ng_f_ss_ct.. f_lg_f_ss_ct =e= ((beta*(1-pig_f)-1)*cg_n_f_ss_ct + (1+tau_p0)*wg_f_ss_ct*hg_f_ss_ct)/(lambdag_f_ss_ct*hg_f_ss_ct);
eqn_f_lg_f_ss_ct.. f_lg_f_ss_ct =e= alphapg_f.l*gammayg0_f.l*( alphapg_f.l* (hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct**rhog )**(1/rhog-1)*(hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**(rhog-1);
eqn_f_vg_f_ss_ct.. f_vg_f_ss_ct =e= (1-alphapg_f.l)*gammayg0_f.l*( alphapg_f.l* (hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct**rhog )**(1/rhog-1)*(vvg_f_ss_ct)**(rhog-1);



eqn_cost_dfg_f_ss_ct(ind).. cost_dfg_f_ss_ct(ind) =e= gammadfg_f(ind)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadfg_d_f(ind)**sig_df(ind))*((p_f_ss_ct(ind))**(1-sig_df(ind))) + (alphadfg_f_f(ind)**sig_df(ind))*(((p_ss_ct(ind)*exch_ss_ct))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_idg_f_ss_ct(ind).. io_idg_f_ss_ct(ind) =e= ((gammadfg_f(ind)*alphadfg_d_f(ind))**sig_df(ind)) * ((p_f_ss_ct(ind))/cost_dfg_f_ss_ct(ind))**(-sig_df(ind));
eqn_io_ifg_f_ss_ct(ind).. io_ifg_f_ss_ct(ind)  =e=  ((gammadfg_f(ind)*alphadfg_f_f(ind))**sig_df(ind)) * (((p_ss_ct(ind)*exch_ss_ct))/cost_dfg_f_ss_ct(ind))**(-sig_df(ind));
eqn_cost_eg_f_ss_ct.. cost_eg_f_ss_ct =e= gammaeg_f**(sig_eg/(1-sig_eg))*( sum(ie, (alphaeg_f(ie)**sig_eg)*(cost_dfg_f_ss_ct(ie))**(1-sig_eg)) )**(1/(1-sig_eg));
eqn_io_ieg_f_ss_ct(ie).. io_ieg_f_ss_ct(ie) =e= ((gammaeg_f*alphaeg_f(ie))**sig_eg) * ((cost_dfg_f_ss_ct(ie))/cost_eg_f_ss_ct)**(-sig_eg);
eqn_cost_mg_f_ss_ct.. cost_mg_f_ss_ct =e= gammamg_f**(sig_mg/(1-sig_mg))*( sum(im, (alphamg_f(im)**sig_mg)*(cost_dfg_f_ss_ct(im))**(1-sig_mg)) )**(1/(1-sig_mg));
eqn_io_img_f_ss_ct(im).. io_img_f_ss_ct(im) =e= ((gammamg_f*alphamg_f(im))**sig_mg) * (cost_dfg_f_ss_ct(im)/cost_mg_f_ss_ct)**(-sig_mg);
eqn_cost_vg_f_ss_ct.. cost_vg_f_ss_ct =e= gammavg_f**(sig_vg/(1-sig_vg))*( (alphavg_e_f**sig_vg)*((cost_eg_f_ss_ct)**(1-sig_vg)) + (alphavg_m_f**sig_vg)*((cost_mg_f_ss_ct)**(1-sig_vg)) )**(1/(1-sig_vg));
eqn_io_evg_f_ss_ct.. io_evg_f_ss_ct =e= ((gammavg_f*alphavg_e_f)**sig_vg) * (cost_eg_f_ss_ct/cost_vg_f_ss_ct)**(-sig_vg);
eqn_io_mvg_f_ss_ct.. io_mvg_f_ss_ct =e= ((gammavg_f*alphavg_m_f)**sig_vg) * (cost_mg_f_ss_ct/cost_vg_f_ss_ct)**(-sig_vg);
eqn_gd_f_e_ss_ct(ie).. gd_f_ss_ct(ie) =e= vvg_f_ss_ct*io_evg_f_ss_ct*io_ieg_f_ss_ct(ie)*io_idg_f_ss_ct(ie);
eqn_gd_f_m_ss_ct(im).. gd_f_ss_ct(im) =e= vvg_f_ss_ct*io_mvg_f_ss_ct*io_img_f_ss_ct(im)*io_idg_f_ss_ct(im);
eqn_gf_f_e_ss_ct(ie).. gf_f_ss_ct(ie) =e= vvg_f_ss_ct*io_evg_f_ss_ct*io_ieg_f_ss_ct(ie)*io_ifg_f_ss_ct(ie);
eqn_gf_f_m_ss_ct(im).. gf_f_ss_ct(im) =e= vvg_f_ss_ct*io_mvg_f_ss_ct*io_img_f_ss_ct(im)*io_ifg_f_ss_ct(im);


eqn_sub_ss_ct(ind).. p_ss_ct(ind)*sub_ss_ct(ind) =e= sum(ie,p_e_ss(ie,ind)*mu_e(ie,ind)*(iod_ss_ct(ie,ind)+iof_ss_ct(ie,ind)) + tar_i2(ie)*p_e_ss(ie,ind)*iof_ss_ct(ie,ind) )/y_ss_ct(ind) ;

eqn_grev_ss_ct.. grev_ss_ct =e= ( (tau_l+tau_p0)*(sum(ind,n_ss_ct(ind)*w_ss_ct(ind)*h_ss_ct(ind)) + ng_ss_ct*wg_ss_ct*hg_ss_ct) + sum(ie,sum(ind,p_e_ss(ie,ind)*mu_e(ie,ind)*(iod_ss_ct(ie,ind)+iof_ss_ct(ie,ind))) ) - sum(ind,p_ss_ct(ind)*sub_ss_ct(ind)*y_ss_ct(ind)) + sum(ind,tar_i2(ind)*sum(ind2,p_e_ss(ind,ind2)*iof_ss_ct(ind,ind2))) + sum(ind,tar_i2(ind)*p_e_c_ss(ind)*cf_ss_ct(ind))   )/p_cbar_ss_ct;
eqn_tlump_ss_ct.. tlump_ss_ct =e= ( grev_ss_ct*p_cbar_ss_ct - (1-ntot_ss_ct)*p_cbar_ss_ct*b0.l - cost_vg_ss_ct*vvg_ss_ct -(1+tau_p0)*ng_ss_ct*wg_ss_ct*hg_ss_ct)/p_cbar_ss_ct;
eqn_vlump_ss_ct.. vlump_ss_ct =e= tlump_ss_ct/(1-beta);

eqn_grev_f_ss_ct.. grev_f_ss_ct =e= ( (tau_l0+tau_p0)*(sum(ind,n_f_ss_ct(ind)*w_f_ss_ct(ind)*h_f_ss_ct(ind)) + ng_f_ss_ct*wg_f_ss_ct*hg_f_ss_ct) )/p_cbar_f_ss_ct;
eqn_tlump_f_ss_ct.. tlump_f_ss_ct =e= ( grev_f_ss_ct*p_cbar_f_ss_ct - (ratiof-ntot_f_ss_ct)*p_cbar_f_ss_ct*b0_f.l -  cost_vg_f_ss_ct*vvg_f_ss_ct -(1+tau_p0)*ng_f_ss_ct*wg_f_ss_ct*hg_f_ss_ct)/p_cbar_f_ss_ct;


** Labor Market

eqn_phi_i_ss_ct(ind).. phi_i_ss_ct(ind) =e= mu.l(ind)*(theta_i_ss_ct(ind)*thetatot_ss_ct**(-gamma));
eqn_q_ss_ct(ind).. q_ss_ct(ind) =e= mu.l(ind)*(thetatot_ss_ct**(-gamma));
eqn_theta_i_ss_ct(ind).. theta_i_ss_ct(ind) =e= (vbar_ss_ct(ind)*n_ss_ct(ind)*h_ss_ct(ind))/(1-ntot_ss_ct);
eqn_n_ss_ct(ind).. n_ss_ct(ind) =e= phi_i_ss_ct(ind)*(1-ntot_ss_ct)/(pi(ind));

eqn_phi_g_ss_ct.. phi_g_ss_ct =e= mug.l*(theta_g_ss_ct*thetatot_ss_ct**(-gamma) );
eqn_qg_ss_ct.. qg_ss_ct =e= mug.l*(thetatot_ss_ct**(-gamma) );
eqn_theta_g_ss_ct.. theta_g_ss_ct =e= hg_ss_ct*vbarg_ss_ct*ng_ss_ct/(1-ntot_ss_ct);
eqn_ng_ss_ct.. ng_ss_ct =e= phi_g_ss_ct*(1-ntot_ss_ct)/(pig);

eqn_thetatot_ss_ct.. thetatot_ss_ct =e= sum(ind,theta_i_ss_ct(ind)) + theta_g_ss_ct;
eqn_ntot_ss_ct.. ntot_ss_ct =e= sum(ind,n_ss_ct(ind)) + ng_ss_ct;


eqn_phi_f_ss_ct(ind).. phi_f_ss_ct(ind) =e= mu_f.l(ind)*theta_f_ss_ct(ind)*thetatot_f_ss_ct**(-gamma);
eqn_q_f_ss_ct(ind).. q_f_ss_ct(ind) =e= mu_f.l(ind)*thetatot_f_ss_ct**(-gamma);
eqn_theta_f_ss_ct(ind).. theta_f_ss_ct(ind) =e= vbar_f_ss_ct(ind)*h_f_ss_ct(ind)*n_f_ss_ct(ind)/(ratiof-ntot_f_ss_ct);
eqn_n_f_ss_ct(ind).. n_f_ss_ct(ind) =e= (ratiof-ntot_f_ss_ct)*phi_f_ss_ct(ind)/(pi_f(ind));

eqn_phig_f_ss_ct.. phig_f_ss_ct =e= mug_f.l*thetag_f_ss_ct*thetatot_f_ss_ct**(-gamma);
eqn_qg_f_ss_ct.. qg_f_ss_ct =e= mug_f.l*thetatot_f_ss_ct**(-gamma);
eqn_thetag_f_ss_ct.. thetag_f_ss_ct =e= vbarg_f_ss_ct*hg_f_ss_ct*ng_f_ss_ct/(ratiof-ntot_f_ss_ct);
eqn_ng_f_ss_ct.. ng_f_ss_ct =e= (ratiof-ntot_f_ss_ct)*phig_f_ss_ct/(pig_f);

eqn_thetatot_f_ss_ct.. thetatot_f_ss_ct =e= (sum(ind,vbar_f_ss_ct(ind)*h_f_ss_ct(ind)*n_f_ss_ct(ind)) + vbarg_f_ss_ct*hg_f_ss_ct*ng_f_ss_ct)/(ratiof-ntot_f_ss_ct);
eqn_ntot_f_ss_ct.. ntot_f_ss_ct =e= sum(ind,n_f_ss_ct(ind)) + ng_f_ss_ct;


** Trade

eqn_imports_ss_ct(ind).. imports_ss_ct(ind) =e= sum(ind2,iof_ss_ct(ind,ind2)) + cf_ss_ct(ind) + gf_ss_ct(ind);
eqn_exports_ss_ct(ind).. exports_ss_ct(ind) =e= sum(ind2,iof_f_ss_ct(ind,ind2)) + cf_f_ss_ct(ind) + gf_f_ss_ct(ind);
eqn_tbal_ss_ct.. sum(ind,p_ss_ct(ind)*exports_ss_ct(ind) - (p_f_ss_ct(ind)/exch_ss_ct)*imports_ss_ct(ind)) =e= 0;

** Market Clearing

eqn_mc_ss_ct(ind).. y_ss_ct(ind) =g= cd_ss_ct(ind) + gd_ss_ct(ind) +  exports_ss_ct(ind) + sum(ind2,iod_ss_ct(ind,ind2));
eqn_mc_f_ss_ct(ind).. y_f_ss_ct(ind) =g= cd_f_ss_ct(ind) + gd_f_ss_ct(ind) +  imports_ss_ct(ind) + sum(ind2,iod_f_ss_ct(ind,ind2));

eqn_yg_ss_ct.. gammayg0.l*( alphapg.l*(hg_ss_ct*ng_ss_ct*(1-vbarg_ss_ct))**rhog + (1-alphapg.l)*vvg_ss_ct**rhog)**(1/rhog) =g= yg0;
eqn_yg_f_ss_ct.. gammayg0_f.l*( alphapg_f.l*(hg_f_ss_ct*ng_f_ss_ct*(1-vbarg_f_ss_ct))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct**rhog)**(1/rhog) =g= yg0_f;


* Initialization

p_ss_ct.l(ind) = 1;
p_ss_ct.fx('i22') = 1;
p_cbar_ss_ct.l = 1;
p_c_ss_ct.l(ind) = 1;
exch_ss_ct.l = 1;

sub_ss_ct.l(ind) = 0;

p_f_ss_ct.l(ind) = 1;
p_f_ss_ct.fx('i22') = 1;
p_cbar_f_ss_ct.l = 1;
p_c_f_ss_ct.l(ind) = 1;


lambda_ss_ct.l = lambda_ss;
lambda_f_ss_ct.l = lambda_f_ss;

lambdag_ss_ct.l = lambdag_ss;
lambdag_f_ss_ct.l = lambdag_f_ss;

cbar_ss_ct.l = cbar_ss;
c_ss_ct.l(ind) = c0(ind);
cd_ss_ct.l(ind) = c_d0(ind);
cf_ss_ct.l(ind) = c_f0(ind);

v_n_ss_ct.l(ind) = v_n_ss.l(ind);
v_ng_ss_ct.l = v_ng_ss.l;
phibar_ss_ct.l = phitot_ss.l;

cbar_f_ss_ct.l = cbar_f_ss;
c_f_ss_ct.l(ind) = c0_f(ind);
cd_f_ss_ct.l(ind) = c_d0_f(ind);
cf_f_ss_ct.l(ind) = c_f0_f(ind);

v_n_f_ss_ct.l(ind) = v_n_f_ss.l(ind);
v_ng_f_ss_ct.l = v_ng_f_ss.l;
phibar_f_ss_ct.l = phitot_f_ss.l;



w_ss_ct.l(ind) = w_ss.l(ind);
h_ss_ct.l(ind) = h_ss.l(ind);
w_f_ss_ct.l(ind) = w_f_ss.l(ind);
h_f_ss_ct.l(ind) = h_f_ss.l(ind);
wg_ss_ct.l = wg_ss.l;
hg_ss_ct.l = hg_ss.l;
wg_f_ss_ct.l = wg_f_ss.l;
hg_f_ss_ct.l = hg_f_ss.l;



vbar_ss_ct.l(ind) = vbar_ss.l(ind);
j_n_ss_ct.l(ind) = j_n_ss.l(ind);
f_l_ss_ct.l(ind) = f_l_ss.l(ind);
f_v_ss_ct.l(ind) = f_v_ss.l(ind);
vv_ss_ct.l(ind) = vv0(ind);
cost_df_ss_ct.l(ind,ind2) = cost_df0(ind,ind2);
io_id_ss_ct.l(ind,ind2) = io_id0(ind,ind2);
io_if_ss_ct.l(ind,ind2) = io_if0(ind,ind2);
cost_e_ss_ct.l(ind) = cost_e0(ind);
io_ie_ss_ct.l(ie,ind) = io_ie0(ie,ind);
cost_m_ss_ct.l(ind) = cost_m0(ind);
io_im_ss_ct.l(im,ind) = io_im0(im,ind);
cost_v_ss_ct.l(ind) = cost_v0(ind);
io_ev_ss_ct.l(ind) = io_ev0(ind);
io_mv_ss_ct.l(ind) = io_mv0(ind);
iod_ss_ct.l(ind,ind2) = iod0(ind,ind2);
iof_ss_ct.l(ind,ind2) = iof0(ind,ind2);

y_ss_ct.l(ind) = y0(ind);
prof_ss_ct.l(ind) = prof_ss(ind);
e_ss_ct.l(ind) = e0(ind);
etot_ss_ct.l = etot0;

vbar_f_ss_ct.l(ind) = vbar_f_ss.l(ind);
j_n_f_ss_ct.l(ind) = j_n_f_ss.l(ind);
f_l_f_ss_ct.l(ind) = f_l_f_ss.l(ind);
f_v_f_ss_ct.l(ind) = f_v_f_ss.l(ind);
vv_f_ss_ct.l(ind) = vv0_f(ind);
cost_df_f_ss_ct.l(ind,ind2) = cost_df0_f(ind,ind2);
io_id_f_ss_ct.l(ind,ind2) = io_id0_f(ind,ind2);
io_if_f_ss_ct.l(ind,ind2) = io_if0_f(ind,ind2);
cost_e_f_ss_ct.l(ind) = cost_e0_f(ind);
io_ie_f_ss_ct.l(ie,ind) = io_ie0_f(ie,ind);
cost_m_f_ss_ct.l(ind) = cost_m0_f(ind);
io_im_f_ss_ct.l(im,ind) = io_im0_f(im,ind);
cost_v_f_ss_ct.l(ind) = cost_v0_f(ind);
io_ev_f_ss_ct.l(ind) = io_ev0_f(ind);
io_mv_f_ss_ct.l(ind) = io_mv0_f(ind);
iod_f_ss_ct.l(ind,ind2) = iod0_f(ind,ind2);
iof_f_ss_ct.l(ind,ind2) = iof0_f(ind,ind2);

y_f_ss_ct.l(ind) = y0_f(ind);
prof_f_ss_ct.l(ind) = prof_f_ss(ind);

vbarg_ss_ct.l = vbarg_ss.l;
cg_n_ss_ct.l = cg_n_ss.l;
f_lg_ss_ct.l = f_lg_ss.l;
f_vg_ss_ct.l = f_vg_ss.l;
vvg_ss_ct.l = gtot0;
io_idg_ss_ct.l(ind) = io_idg0(ind);
io_ifg_ss_ct.l(ind) = io_ifg0(ind);
cost_dfg_ss_ct.l(ind) = cost_dfg0(ind);
cost_eg_ss_ct.l = cost_eg0;
io_ieg_ss_ct.l(ie) = io_ieg0(ie);
cost_mg_ss_ct.l = cost_mg0;
io_img_ss_ct.l(im) = io_img0(im);
cost_vg_ss_ct.l = cost_vg0;
io_evg_ss_ct.l = io_evg0;
io_mvg_ss_ct.l = io_mvg0;
gd_ss_ct.l(ind) = g_d0(ind);
gf_ss_ct.l(ind) = g_f0(ind);

vbarg_f_ss_ct.l = vbarg_f_ss.l;
cg_n_f_ss_ct.l = cg_n_f_ss.l;
f_lg_f_ss_ct.l = f_lg_f_ss.l;
f_vg_f_ss_ct.l = f_vg_f_ss.l;
vvg_f_ss_ct.l = gtot0_f;
io_idg_f_ss_ct.l(ind) = io_idg0_f(ind);
io_ifg_f_ss_ct.l(ind) = io_ifg0_f(ind);
cost_dfg_f_ss_ct.l(ind) = cost_dfg0_f(ind);
cost_eg_f_ss_ct.l = cost_eg0_f;
io_ieg_f_ss_ct.l(ie) = io_ieg0_f(ie);
cost_mg_f_ss_ct.l = cost_mg0_f;
io_img_f_ss_ct.l(im) = io_img0_f(im);
cost_vg_f_ss_ct.l = cost_vg0_f;
io_evg_f_ss_ct.l = io_evg0_f;
io_mvg_f_ss_ct.l = io_mvg0_f;
gd_f_ss_ct.l(ind) = g_d0_f(ind);
gf_f_ss_ct.l(ind) = g_f0_f(ind);

phi_i_ss_ct.l(ind) = phi_i_ss.l(ind);
q_ss_ct.l(ind) = q_ss.l(ind);
theta_i_ss_ct.l(ind) = theta_i_ss.l(ind);
n_ss_ct.l(ind) = n_ss.l(ind);

phi_g_ss_ct.l = phi_g_ss.l;
qg_ss_ct.l = qg_ss.l;
theta_g_ss_ct.l = theta_g_ss.l;
ng_ss_ct.l = ng_ss.l;

thetatot_ss_ct.l = thetatot_ss.l;
ntot_ss_ct.l = ntot_ss.l;

phi_f_ss_ct.l(ind) = phi_f_ss.l(ind);
q_f_ss_ct.l(ind) = q_f_ss.l(ind);
theta_f_ss_ct.l(ind) = theta_f_ss.l(ind);
n_f_ss_ct.l(ind) = n_f_ss.l(ind);

phig_f_ss_ct.l = phig_f_ss.l;
qg_f_ss_ct.l = qg_f_ss.l;
thetag_f_ss_ct.l = thetag_f_ss.l;
ng_f_ss_ct.l = ng_f_ss.l;

thetatot_f_ss_ct.l = thetatot_f_ss.l;
ntot_f_ss_ct.l = ntot_f_ss.l;

grev_ss_ct.l = grev_ss;
tlump_ss_ct.l = tlump_ss;
vlump_ss_ct.l = vlump_ss;

grev_f_ss_ct.l = grev_f_ss;
tlump_f_ss_ct.l = tlump_f_ss;

exports_ss_ct.l(ind) = exports0(ind) ;
imports_ss_ct.l(ind) = imports0(ind);



model hwc_ss_ct /
eqn_p_cbar_ss_ct.p_cbar_ss_ct
eqn_p_c_ss_ct.p_c_ss_ct


eqn_p_cbar_f_ss_ct.p_cbar_f_ss_ct
eqn_p_c_f_ss_ct.p_c_f_ss_ct

eqn_hhfoc_ss_ct.cbar_ss_ct
eqn_bc_ss_ct.lambda_ss_ct
eqn_c_ss_ct.c_ss_ct
eqn_cd_ss_ct.cd_ss_ct
eqn_cf_ss_ct.cf_ss_ct

eqn_v_n_ss_ct.v_n_ss_ct
eqn_v_ng_ss_ct.v_ng_ss_ct
eqn_phibar_ss_ct.phibar_ss_ct

eqn_hhfoc_f_ss_ct.cbar_f_ss_ct
eqn_bc_f_ss_ct.lambda_f_ss_ct
eqn_c_f_ss_ct.c_f_ss_ct
eqn_cd_f_ss_ct.cd_f_ss_ct
eqn_cf_f_ss_ct.cf_f_ss_ct

eqn_nash_ss_ct.w_ss_ct
eqn_intra_ss_ct.h_ss_ct
eqn_nashg_ss_ct.wg_ss_ct
eqn_intrag_ss_ct.hg_ss_ct

eqn_nash_f_ss_ct.w_f_ss_ct
eqn_intra_f_ss_ct.h_f_ss_ct
eqn_nashg_f_ss_ct.wg_f_ss_ct
eqn_intrag_f_ss_ct.hg_f_ss_ct

eqn_foc_vbar_ss_ct.vbar_ss_ct
eqn_foc_v_ss_ct.vv_ss_ct
eqn_foc_n_ss_ct.j_n_ss_ct
eqn_f_l_ss_ct.f_l_ss_ct
eqn_f_v_ss_ct.f_v_ss_ct
eqn_cost_df_ss_ct.cost_df_ss_ct
eqn_io_id_ss_ct.io_id_ss_ct
eqn_io_if_ss_ct.io_if_ss_ct
eqn_cost_e_ss_ct.cost_e_ss_ct
eqn_io_ie_ss_ct.io_ie_ss_ct
eqn_cost_m_ss_ct.cost_m_ss_ct
eqn_io_im_ss_ct.io_im_ss_ct
eqn_cost_v_ss_ct.cost_v_ss_ct
eqn_io_ev_ss_ct.io_ev_ss_ct
eqn_io_mv_ss_ct.io_mv_ss_ct
eqn_firm_iod_e_ss_ct.iod_ss_ct
eqn_firm_iod_m_ss_ct.iod_ss_ct
eqn_firm_iof_e_ss_ct.iof_ss_ct
eqn_firm_iof_m_ss_ct.iof_ss_ct
eqn_y_ss_ct.y_ss_ct
eqn_prof_ss_ct.prof_ss_ct
eqn_e_ss_ct.e_ss_ct
eqn_etot_ss_ct.etot_ss_ct

eqn_foc_vbar_f_ss_ct.vbar_f_ss_ct
eqn_foc_v_f_ss_ct.vv_f_ss_ct
eqn_foc_n_f_ss_ct.j_n_f_ss_ct
eqn_f_l_f_ss_ct.f_l_f_ss_ct
eqn_f_v_f_ss_ct.f_v_f_ss_ct
eqn_cost_df_f_ss_ct.cost_df_f_ss_ct
eqn_io_id_f_ss_ct.io_id_f_ss_ct
eqn_io_if_f_ss_ct.io_if_f_ss_ct
eqn_cost_e_f_ss_ct.cost_e_f_ss_ct
eqn_io_ie_f_ss_ct.io_ie_f_ss_ct
eqn_cost_m_f_ss_ct.cost_m_f_ss_ct
eqn_io_im_f_ss_ct.io_im_f_ss_ct
eqn_cost_v_f_ss_ct.cost_v_f_ss_ct
eqn_io_ev_f_ss_ct.io_ev_f_ss_ct
eqn_io_mv_f_ss_ct.io_mv_f_ss_ct
eqn_firm_iod_e_f_ss_ct.iod_f_ss_ct
eqn_firm_iod_m_f_ss_ct.iod_f_ss_ct
eqn_firm_iof_e_f_ss_ct.iof_f_ss_ct
eqn_firm_iof_m_f_ss_ct.iof_f_ss_ct
eqn_y_f_ss_ct.y_f_ss_ct
eqn_prof_f_ss_ct.prof_f_ss_ct

eqn_foc_vbarg_ss_ct.vbarg_ss_ct
eqn_foc_vg_ss_ct.vvg_ss_ct
eqn_foc_ng_ss_ct.cg_n_ss_ct
eqn_f_lg_ss_ct.f_lg_ss_ct
eqn_f_vg_ss_ct.f_vg_ss_ct
eqn_cost_dfg_ss_ct.cost_dfg_ss_ct
eqn_io_idg_ss_ct.io_idg_ss_ct
eqn_io_ifg_ss_ct.io_ifg_ss_ct
eqn_cost_eg_ss_ct.cost_eg_ss_ct
eqn_io_ieg_ss_ct.io_ieg_ss_ct
eqn_cost_mg_ss_ct.cost_mg_ss_ct
eqn_io_img_ss_ct.io_img_ss_ct
eqn_cost_vg_ss_ct.cost_vg_ss_ct
eqn_io_evg_ss_ct.io_evg_ss_ct
eqn_io_mvg_ss_ct.io_mvg_ss_ct
eqn_gd_e_ss_ct.gd_ss_ct
eqn_gd_m_ss_ct.gd_ss_ct
eqn_gf_e_ss_ct.gf_ss_ct
eqn_gf_m_ss_ct.gf_ss_ct

eqn_foc_vbarg_f_ss_ct.vbarg_f_ss_ct
eqn_foc_vg_f_ss_ct.vvg_f_ss_ct
eqn_foc_ng_f_ss_ct.cg_n_f_ss_ct
eqn_f_lg_f_ss_ct.f_lg_f_ss_ct
eqn_f_vg_f_ss_ct.f_vg_f_ss_ct
eqn_cost_dfg_f_ss_ct.cost_dfg_f_ss_ct
eqn_io_idg_f_ss_ct.io_idg_f_ss_ct
eqn_io_ifg_f_ss_ct.io_ifg_f_ss_ct
eqn_cost_eg_f_ss_ct.cost_eg_f_ss_ct
eqn_io_ieg_f_ss_ct.io_ieg_f_ss_ct
eqn_cost_mg_f_ss_ct.cost_mg_f_ss_ct
eqn_io_img_f_ss_ct.io_img_f_ss_ct
eqn_cost_vg_f_ss_ct.cost_vg_f_ss_ct
eqn_io_evg_f_ss_ct.io_evg_f_ss_ct
eqn_io_mvg_f_ss_ct.io_mvg_f_ss_ct
eqn_gd_f_e_ss_ct.gd_f_ss_ct
eqn_gd_f_m_ss_ct.gd_f_ss_ct
eqn_gf_f_e_ss_ct.gf_f_ss_ct
eqn_gf_f_m_ss_ct.gf_f_ss_ct


eqn_sub_ss_ct.sub_ss_ct

eqn_grev_ss_ct.grev_ss_ct
eqn_tlump_ss_ct.tlump_ss_ct
eqn_vlump_ss_ct.vlump_ss_ct

eqn_grev_f_ss_ct.grev_f_ss_ct
eqn_tlump_f_ss_ct.tlump_f_ss_ct

eqn_phi_i_ss_ct.phi_i_ss_ct
eqn_q_ss_ct.q_ss_ct
eqn_theta_i_ss_ct.theta_i_ss_ct
eqn_n_ss_ct.n_ss_ct

eqn_phi_g_ss_ct.phi_g_ss_ct
eqn_qg_ss_ct.qg_ss_ct
eqn_theta_g_ss_ct.theta_g_ss_ct
eqn_ng_ss_ct.ng_ss_ct

eqn_thetatot_ss_ct.thetatot_ss_ct
eqn_ntot_ss_ct.ntot_ss_ct

eqn_phi_f_ss_ct.phi_f_ss_ct
eqn_q_f_ss_ct.q_f_ss_ct
eqn_theta_f_ss_ct.theta_f_ss_ct
eqn_n_f_ss_ct.n_f_ss_ct
eqn_phig_f_ss_ct.phig_f_ss_ct
eqn_qg_f_ss_ct.qg_f_ss_ct
eqn_thetag_f_ss_ct.thetag_f_ss_ct
eqn_ng_f_ss_ct.ng_f_ss_ct
eqn_thetatot_f_ss_ct.thetatot_f_ss_ct
eqn_ntot_f_ss_ct.ntot_f_ss_ct

eqn_exports_ss_ct.exports_ss_ct
eqn_imports_ss_ct.imports_ss_ct
eqn_tbal_ss_ct.exch_ss_ct

eqn_mc_ss_ct.p_ss_ct
eqn_yg_ss_ct.lambdag_ss_ct
eqn_mc_f_ss_ct.p_f_ss_ct
eqn_yg_f_ss_ct.lambdag_f_ss_ct/
;


* Transition Model

parameters
n0
ng0
n0_f
ng0_f

p_e(ind,ind2,t)
p_e_c(ind,t)
;

variables
p(ind,t)
p_c(ind,t)
p_cbar(t)
exch(t)

sub(ind,t)

p_f(ind,t)
p_c_f(ind,t)
p_cbar_f(t)

lambda(t)
lambda_f(t)

lambdag(t)
lambdag_f(t)


cbar(t)
c(ind,t)
cd(ind,t)
cf(ind,t)
m(t)
v_n(ind,t)
v_ng(t)
phibar(t)


cbar_f(t)
c_f(ind,t)
cd_f(ind,t)
cf_f(ind,t)
m_f(t)
v_n_f(ind,t)
v_ng_f(t)
phibar_f(t)


w0(ind,t)
wdelta(ind,t)
wstar(ind,t)
w(ind,t)
h(ind,t)
w_f(ind,t)
h_f(ind,t)
wg0(t)
wgdelta(t)
wgstar(t)
wg(t)
hg(t)
wg_f(t)
hg_f(t)

vbar(ind,t)
j_n(ind,t)
f_l(ind,t)
f_v(ind,t)
vv(ind,t)
fire(ind,t)
io_id(ind,ind2,t)
io_if(ind,ind2,t)
cost_df(ind,ind2,t)
cost_e(ind,t)
io_ie(ie,ind,t)
cost_m(ind,t)
io_im(im,ind,t)
cost_v(ind,t)
io_ev(ind,t)
io_mv(ind,t)
iod(ind,ind2,t)
iof(ind,ind2,t)
y(ind,t)
prof(ind,t)
fire(ind,t)
e(ind,t)
etot(t)

vbar_f(ind,t)
j_n_f(ind,t)
f_l_f(ind,t)
f_v_f(ind,t)
vv_f(ind,t)
fire_f(ind,t)
io_id_f(ind,ind2,t)
io_if_f(ind,ind2,t)
cost_df_f(ind,ind2,t)
cost_e_f(ind,t)
io_ie_f(ie,ind,t)
cost_m_f(ind,t)
io_im_f(im,ind,t)
cost_v_f(ind,t)
io_ev_f(ind,t)
io_mv_f(ind,t)
iod_f(ind,ind2,t)
iof_f(ind,ind2,t)
y_f(ind,t)
prof_f(ind,t)

vbarg(t)
cg_n(t)
f_lg(t)
f_vg(t)
vvg(t)
io_idg(ind,t)
io_ifg(ind,t)
cost_dfg(ind,t)
cost_eg(t)
io_ieg(ie,t)
cost_mg(t)
io_img(im,t)
cost_vg(t)
io_evg(t)
io_mvg(t)
gd(ind,t)
gf(ind,t)


vbarg_f(t)
cg_n_f(t)
f_lg_f(t)
f_vg_f(t)
vvg_f(t)
io_idg_f(ind,t)
io_ifg_f(ind,t)
cost_dfg_f(ind,t)
cost_eg_f(t)
io_ieg_f(ie,t)
cost_mg_f(t)
io_img_f(im,t)
cost_vg_f(t)
io_evg_f(t)
io_mvg_f(t)
gd_f(ind,t)
gf_f(ind,t)

phi_i(ind,t)
q(ind,t)
theta_i(ind,t)
n(ind,t)

phi_g(t)
qg(t)
theta_g(t)
ng(t)

thetatot(t)
ntot(t)

phi_f(ind,t)
q_f(ind,t)
theta_f(ind,t)
n_f(ind,t)
phig_f(t)
qg_f(t)
thetag_f(t)
ng_f(t)
thetatot_f(t)
ntot_f(t)

grev(t)
tlump(t)
vlump(t)


grev_f(t)
tlump_f(t)

exports(ind,t)
imports(ind,t)
;



;

equations

eqn_p_cbar(t)
eqn_p_c(ind,t)


eqn_p_cbar_f(t)
eqn_p_c_f(ind,t)

eqn_hhfoc(t)
eqn_hheuler(t)
eqn_hheuler_tc(t)
eqn_bc(t)
eqn_c(ind,t)
eqn_cd(ind,t)
eqn_cf(ind,t)
eqn_v_n(ind,t)
eqn_v_n_tc(ind,t)
eqn_v_ng(t)
eqn_v_ng_tc(t)
eqn_phibar(t)
eqn_phibar_tc(t)


eqn_hhfoc_f(t)
eqn_hheuler_f(t)
eqn_hheuler_f_tc(t)
eqn_bc_f(t)
eqn_c_f(ind,t)
eqn_cd_f(ind,t)
eqn_cf_f(ind,t)
eqn_v_n_f(ind,t)
eqn_v_n_f_tc(ind,t)
eqn_v_ng_f(t)
eqn_v_ng_f_tc(t)
eqn_phibar_f(t)
eqn_phibar_f_tc(t)



eqn_nash(ind,t)
eqn_intra(ind,t)

eqn_nash_f(ind,t)
eqn_intra_f(ind,t)

eqn_nashg(t)
eqn_intrag(t)

eqn_nashg_f(t)
eqn_intrag_f(t)


eqn_foc_vbar(ind,t)
eqn_foc_vbar_tc(ind,t)
eqn_foc_n(ind,t)
eqn_foc_n_tc(ind,t)
eqn_foc_v(ind,t)
eqn_f_l(ind,t)
eqn_f_v(ind,t)
eqn_cost_df(ind,ind2,t)
eqn_io_id(ind,ind2,t)
eqn_io_if(ind,ind2,t)
eqn_cost_e(ind,t)
eqn_io_ie(ie,ind,t)
eqn_cost_m(ind,t)
eqn_io_im(im,ind,t)
eqn_cost_v(ind,t)
eqn_io_ev(ind,t)
eqn_io_mv(ind,t)
eqn_firm_iod_e(ie,ind,t)
eqn_firm_iod_m(im,ind,t)
eqn_firm_iof_e(ie,ind,t)
eqn_firm_iof_m(im,ind,t)
eqn_y(ind,t)
eqn_prof(ind,t)
eqn_fire(ind,t)
eqn_e(ind,t)
eqn_etot(t)


eqn_foc_vbar_f(ind,t)
eqn_foc_vbar_f_tc(ind,t)
eqn_foc_n_f(ind,t)
eqn_foc_n_f_tc(ind,t)
eqn_foc_v_f(ind,t)
eqn_f_l_f(ind,t)
eqn_f_v_f(ind,t)
eqn_cost_df_f(ind,ind2,t)
eqn_io_id_f(ind,ind2,t)
eqn_io_if_f(ind,ind2,t)
eqn_cost_e_f(ind,t)
eqn_io_ie_f(ie,ind,t)
eqn_cost_m_f(ind,t)
eqn_io_im_f(im,ind,t)
eqn_cost_v_f(ind,t)
eqn_io_ev_f(ind,t)
eqn_io_mv_f(ind,t)
eqn_firm_iod_e_f(ie,ind,t)
eqn_firm_iod_m_f(im,ind,t)
eqn_firm_iof_e_f(ie,ind,t)
eqn_firm_iof_m_f(im,ind,t)
eqn_y_f(ind,t)
eqn_prof_f(ind,t)
eqn_fire_f(ind,t)

eqn_foc_vbarg(t)
eqn_foc_vbarg_tc(t)
eqn_foc_ng(t)
eqn_foc_ng_tc(t)
eqn_foc_vg(t)
eqn_f_lg(t)
eqn_f_vg(t)
eqn_cost_dfg(ind,t)
eqn_io_idg(ind,t)
eqn_io_ifg(ind,t)
eqn_cost_eg(t)
eqn_io_ieg(ie,t)
eqn_cost_mg(t)
eqn_io_img(im,t)
eqn_cost_vg(t)
eqn_io_evg(t)
eqn_io_mvg(t)
eqn_gd_e(ie,t)
eqn_gd_m(im,t)
eqn_gf_e(ie,t)
eqn_gf_m(im,t)

eqn_foc_vbarg_f(t)
eqn_foc_vbarg_f_tc(t)
eqn_foc_ng_f(t)
eqn_foc_ng_f_tc(t)
eqn_foc_vg_f(t)
eqn_f_lg_f(t)
eqn_f_vg_f(t)
eqn_cost_dfg_f(ind,t)
eqn_io_idg_f(ind,t)
eqn_io_ifg_f(ind,t)
eqn_cost_eg_f(t)
eqn_io_ieg_f(ie,t)
eqn_cost_mg_f(t)
eqn_io_img_f(im,t)
eqn_cost_vg_f(t)
eqn_io_evg_f(t)
eqn_io_mvg_f(t)
eqn_gd_f_e(ie,t)
eqn_gd_f_m(im,t)
eqn_gf_f_e(ie,t)
eqn_gf_f_m(im,t)


eqn_phi_i(ind,t)
eqn_q(ind,t)
eqn_theta_i(ind,t)
eqn_n(ind,t)

eqn_phi_g(t)
eqn_qg(t)
eqn_theta_g(t)
eqn_ng(t)

eqn_thetatot(t)
eqn_ntot(t)

eqn_phi_f(ind,t)
eqn_q_f(ind,t)
eqn_theta_f(ind,t)
eqn_n_f(ind,t)
eqn_phig_f(t)
eqn_qg_f(t)
eqn_thetag_f(t)
eqn_ng_f(t)
eqn_thetatot_f(t)
eqn_ntot_f(t)

eqn_sub(ind,t)

eqn_grev(t)
eqn_tlump(t)
eqn_vlump(t)
eqn_vlump_tc(t)

eqn_grev_f(t)
eqn_tlump_f(t)

eqn_exports(ind,t)
eqn_imports(ind,t)
eqn_tbal(t)

eqn_mc(ind,t)
eqn_mc_f(ind,t)
eqn_yg(t)
eqn_yg_f(t)
;


** Aggregate Prices

eqn_p_cbar(t).. p_cbar(t) =e= gammac**(sigmac/(1-sigmac))*(sum(ind,(alphac(ind)**sigmac)*p_c(ind,t)**(1-sigmac)))**(1/(1-sigmac));
eqn_p_c(ind,t).. p_c(ind,t) =e= gammacf(ind)**(sig_c(ind)/(1-sig_c(ind)))*( (alphac_d(ind)**sig_c(ind))*((p(ind,t))**(1-sig_c(ind))) + (alphac_f(ind)**sig_c(ind))*(((p_f(ind,t)/exch(t))+tar_i2(ind)*p_e_c(ind,t))**(1-sig_c(ind))) )**(1/(1-sig_c(ind)));



eqn_p_cbar_f(t).. p_cbar_f(t) =e= gammac_ff**(sigmac/(1-sigmac))*(sum(ind,(alphac_ff(ind)**sigmac)*p_c_f(ind,t)**(1-sigmac)))**(1/(1-sigmac));
eqn_p_c_f(ind,t).. p_c_f(ind,t) =e= gammacf_f(ind)**(sig_c_f(ind)/(1-sig_c_f(ind)))*( (alphac_d_f(ind)**sig_c_f(ind))*((p_f(ind,t))**(1-sig_c_f(ind))) + (alphac_f_f(ind)**sig_c_f(ind))*(((p(ind,t)*exch(t)) )**(1-sig_c_f(ind))) )**(1/(1-sig_c_f(ind)));


** Household


eqn_hhfoc(t).. cbar(t)**(-sigma) =e= p_cbar(t)*lambda(t);
eqn_hheuler(t)$(not tlast(t)).. m(t) =e= beta*lambda(t+1)/lambda(t);
eqn_hheuler_tc(tlast).. m(tlast) =e= beta*lambda_ss_ct/lambda(tlast);
eqn_bc(t).. (1-tau_l)*(sum(ind,n(ind,t)*w(ind,t)*h(ind,t)) + ng(t)*wg(t)*hg(t)) + (1-ntot(t))*p_cbar(t)*b0.l + p_cbar(t)*tlump(t)  + sum(ind,prof(ind,t))  - p_cbar(t)*cbar(t) =g= 0;
eqn_c(ind,t).. c(ind,t) =e= ((gammac*alphac(ind))**sigmac)*((p_cbar(t)/p_c(ind,t))**sigmac)*cbar(t);
eqn_cd(ind,t).. cd(ind,t) =e= ((gammacf(ind)*alphac_d(ind))**sig_c(ind))*((p_c(ind,t)/p(ind,t))**sig_c(ind))*c(ind,t);
eqn_cf(ind,t).. cf(ind,t) =e= ((gammacf(ind)*alphac_f(ind))**sig_c(ind))*((p_c(ind,t)/((p_f(ind,t)/exch(t))+tar_i2(ind)*p_e_c(ind,t)))**sig_c(ind))*c(ind,t);


eqn_v_n(ind,t)$(not tlast(t)).. v_n(ind,t) =e= lambda(t)*((1-tau_l)*w(ind,t)*h(ind,t) - b0.l*p_cbar(t)) - psi.l*(h(ind,t)**(1+chi))/(1+chi) - phibar(t) + beta*(1-pi(ind))*v_n(ind,t+1);
eqn_v_n_tc(ind,tlast).. v_n(ind,tlast) =e= lambda(tlast)*((1-tau_l)*w(ind,tlast)*h(ind,tlast) - b0.l*p_cbar(tlast)) - psi.l*(h(ind,tlast)**(1+chi))/(1+chi) - phibar(tlast) + beta*(1-pi(ind))*v_n_ss_ct(ind);

eqn_v_ng(t)$(not tlast(t)).. v_ng(t) =e= lambda(t)*((1-tau_l)*wg(t)*hg(t) - b0.l*p_cbar(t)) - psi.l*(hg(t)**(1+chi))/(1+chi) - phibar(t) + beta*(1-pig)*v_ng(t+1);
eqn_v_ng_tc(tlast).. v_ng(tlast) =e= lambda(tlast)*((1-tau_l)*wg(tlast)*hg(tlast) - b0.l*p_cbar(tlast)) - psi.l*(hg(tlast)**(1+chi))/(1+chi) - phibar(tlast) + beta*(1-pig)*v_ng_ss_ct;

eqn_phibar(t)$(not tlast(t)).. phibar(t) =e= beta*sum(ind,phi_i(ind,t)*v_n(ind,t+1)) + beta*phi_g(t)*v_ng(t+1);
eqn_phibar_tc(tlast).. phibar(tlast) =e= beta*sum(ind,phi_i(ind,tlast)*v_n_ss_ct(ind)) + beta*phi_g(tlast)*v_ng_ss_ct;


eqn_hhfoc_f(t).. (cbar_f(t)/ratiof)**(-sigma) =e= p_cbar_f(t)*lambda_f(t);
eqn_hheuler_f(t)$(not tlast(t)).. m_f(t) =e= beta*lambda_f(t+1)/lambda_f(t);
eqn_hheuler_f_tc(tlast).. m_f(tlast) =e= beta*lambda_f_ss_ct/lambda_f(tlast);
eqn_bc_f(t).. (1-tau_l0)*(sum(ind,n_f(ind,t)*w_f(ind,t)*h_f(ind,t)) + ng_f(t)*wg_f(t)*hg_f(t)) + (ratiof-ntot_f(t))*p_cbar_f(t)*b0_f.l + p_cbar_f(t)*tlump_f(t)  + sum(ind,prof_f(ind,t))  - p_cbar_f(t)*cbar_f(t) =g= 0;
eqn_c_f(ind,t).. c_f(ind,t) =e= ((gammac_ff*alphac_ff(ind))**sigmac)*((p_cbar_f(t)/p_c_f(ind,t))**sigmac)*cbar_f(t);
eqn_cd_f(ind,t).. cd_f(ind,t) =e= ((gammacf_f(ind)*alphac_d_f(ind))**sig_c_f(ind))*((p_c_f(ind,t)/p_f(ind,t))**sig_c_f(ind))*c_f(ind,t);
eqn_cf_f(ind,t).. cf_f(ind,t) =e= ((gammacf_f(ind)*alphac_f_f(ind))**sig_c_f(ind))*((p_c_f(ind,t)/((p(ind,t)*exch(t))))**sig_c_f(ind))*c_f(ind,t);

eqn_v_n_f(ind,t)$(not tlast(t)).. v_n_f(ind,t) =e= lambda_f(t)*((1-tau_l0)*w_f(ind,t)*h_f(ind,t) - b0_f.l*p_cbar_f(t)) - psi_f.l*(h_f(ind,t)**(1+chi))/(1+chi) - phibar_f(t) + beta*(1-pi_f(ind))*v_n_f(ind,t+1);
eqn_v_n_f_tc(ind,tlast).. v_n_f(ind,tlast) =e= lambda_f(tlast)*((1-tau_l0)*w_f(ind,tlast)*h_f(ind,tlast) - b0_f.l*p_cbar_f(tlast)) - psi_f.l*(h_f(ind,tlast)**(1+chi))/(1+chi) - phibar_f(tlast) + beta*(1-pi_f(ind))*v_n_f_ss_ct(ind);

eqn_v_ng_f(t)$(not tlast(t)).. v_ng_f(t) =e= lambda_f(t)*((1-tau_l0)*wg_f(t)*hg_f(t) - b0_f.l*p_cbar_f(t)) - psi_f.l*(hg_f(t)**(1+chi))/(1+chi) - phibar_f(t) + beta*(1-pig_f)*v_ng_f(t+1);
eqn_v_ng_f_tc(tlast).. v_ng_f(tlast) =e= lambda_f(tlast)*((1-tau_l0)*wg_f(tlast)*hg_f(tlast) - b0_f.l*p_cbar_f(tlast)) - psi_f.l*(hg_f(tlast)**(1+chi))/(1+chi) - phibar_f(tlast) + beta*(1-pig_f)*v_ng_f_ss_ct;


eqn_phibar_f(t)$(not tlast(t)).. phibar_f(t) =e= beta*sum(ind,phi_f(ind,t)*v_n_f(ind,t+1)) + beta*phig_f(t)*v_ng_f(t+1);
eqn_phibar_f_tc(tlast).. phibar_f(tlast) =e= beta*sum(ind,phi_f(ind,tlast)*v_n_f_ss_ct(ind)) + beta*phig_f(tlast)*v_ng_f_ss_ct;

** Nash Bargaining



eqn_nash(ind,t).. (1-tau_l)*w(ind,t)*h(ind,t) =e= ((1-tau_l)/(1+tau_p0))*(1-tau)*( f_l(ind,t)*h(ind,t)*(p(ind,t)*(1+sub(ind,t)))  )
 + tau*((psi.l*(h(ind,t)**(1+chi))/(1+chi))/lambda(t) + b0.l*p_cbar(t) + phibar(t)/lambda(t));
eqn_intra(ind,t).. (1-tau_l)*lambda(t)*(f_l(ind,t)*p(ind,t)*(1+sub(ind,t))) =e= (1+tau_p0)*psi.l*(h(ind,t)**chi);

eqn_nash_f(ind,t).. (1-tau_l0)*w_f(ind,t)*h_f(ind,t) =e= ((1-tau_l0)/(1+tau_p0))*(1-tau)*( f_l_f(ind,t)*h_f(ind,t)*(p_f(ind,t)) + sum(ind2,(f_l_f(ind2,t)*p_f(ind2,t))*theta_f(ind2,t)) + lambdag_f(t)*f_lg_f(t)*thetag_f(t) )
 + tau*((psi_f.l*(h_f(ind,t)**(1+chi))/(1+chi))/lambda_f(t) + b0_f.l*p_cbar_f(t));
eqn_intra_f(ind,t).. (1-tau_l0)*lambda_f(t)*(f_l_f(ind,t)*p_f(ind,t)) =e= (1+tau_p0)*psi_f.l*(h_f(ind,t)**chi);


eqn_nashg(t).. (1-tau_l)*wg(t)*hg(t) =e= ((1-tau_l)/(1+tau_p0))*(1-tau)*( f_lg(t)*hg(t)*(lambdag(t))  )
 + tau*((psi.l*(hg(t)**(1+chi))/(1+chi))/lambda(t) + b0.l*p_cbar(t) + phibar(t)/lambda(t));
eqn_intrag(t).. (1-tau_l)*lambda(t)*(f_lg(t)*lambdag(t)) =e= (1+tau_p0)*psi.l*(hg(t)**chi);

eqn_nashg_f(t).. (1-tau_l0)*wg_f(t)*hg_f(t) =e= ((1-tau_l0)/(1+tau_p0))*(1-tau)*( f_lg_f(t)*hg_f(t)*(lambdag_f(t)) + sum(ind2,(f_l_f(ind2,t)*p_f(ind2,t))*theta_f(ind2,t)) + lambdag_f(t)*f_lg_f(t)*thetag_f(t) )
 + tau*((psi_f.l*(hg_f(t)**(1+chi))/(1+chi))/lambda_f(t) + b0_f.l*p_cbar_f(t));
eqn_intrag_f(t).. (1-tau_l0)*lambda_f(t)*(f_lg_f(t)*lambdag_f(t)) =e= (1+tau_p0)*psi_f.l*(hg_f(t)**chi);


* First-order conditions for recruitment and intermediate inputs


eqn_foc_vbar(ind,t)$(not tlast(t)).. (f_l(ind,t))*(p(ind,t)*(1+sub(ind,t))) =e= m(t)*q(ind,t)*j_n(ind,t+1);
eqn_foc_vbar_tc(ind,tlast).. (f_l(ind,tlast))*(p(ind,tlast)*(1+sub(ind,tlast))) =e= m(tlast)*q(ind,tlast)*j_n_ss_ct(ind);
eqn_foc_n(ind,t)$(not tlast(t)).. j_n(ind,t) =e= f_l(ind,t)*h(ind,t)*(p(ind,t)*(1+sub(ind,t))) - (1+tau_p0)*w(ind,t)*h(ind,t) + (1-pi(ind))*m(t)*j_n(ind,t+1);
eqn_foc_n_tc(ind,tlast).. j_n(ind,tlast) =e= f_l(ind,tlast)*h(ind,tlast)*(p(ind,tlast)*(1+sub(ind,tlast))) - (1+tau_p0)*w(ind,tlast)*h(ind,tlast) + (1-pi(ind))*m(tlast)*j_n_ss_ct(ind);
eqn_foc_v(ind,t).. f_v(ind,t) =e= cost_v(ind,t)/(p(ind,t)*(1+sub(ind,t)));
eqn_f_l(ind,t).. f_l(ind,t) =e= alphap.l(ind)*gammay(ind,t)*( alphap.l(ind)* (h(ind,t)*n(ind,t)*(1-vbar(ind,t)))**rho(ind) + (1-alphap.l(ind))*vv(ind,t)**rho(ind) )**(1/rho(ind)-1)*(h(ind,t)*n(ind,t)*(1-vbar(ind,t)))**(rho(ind)-1);
eqn_f_v(ind,t).. f_v(ind,t) =e= (1-alphap.l(ind))*gammay(ind,t)*( alphap.l(ind)* (h(ind,t)*n(ind,t)*(1-vbar(ind,t)))**rho(ind) + (1-alphap.l(ind))*vv(ind,t)**rho(ind) )**(1/rho(ind)-1)*vv(ind,t)**(rho(ind)-1);


eqn_foc_vbar_f(ind,t)$(not tlast(t)).. (f_l_f(ind,t))*(p_f(ind,t)) =e= m_f(t)*q_f(ind,t)*j_n_f(ind,t+1);
eqn_foc_vbar_f_tc(ind,tlast).. vbar_f(ind,tlast) =e= vbar_f_ss_ct(ind);
eqn_foc_n_f(ind,t)$(not tlast(t)).. j_n_f(ind,t) =e= f_l_f(ind,t)*h_f(ind,t)*(p_f(ind,t)) - (1+tau_p0)*w_f(ind,t)*h_f(ind,t) + (1-pi_f(ind))*m_f(t)*j_n_f(ind,t+1);
eqn_foc_n_f_tc(ind,tlast).. j_n_f(ind,tlast) =e= f_l_f(ind,tlast)*h_f(ind,tlast)*(p_f(ind,tlast)) - (1+tau_p0)*w_f(ind,tlast)*h_f(ind,tlast) + (1-pi_f(ind))*m_f(tlast)*j_n_f_ss_ct(ind);
eqn_foc_v_f(ind,t).. f_v_f(ind,t) =e= cost_v_f(ind,t)/(p_f(ind,t));
eqn_f_l_f(ind,t).. f_l_f(ind,t) =e= alphap_f.l(ind)*gammay0_f.l(ind)*( alphap_f.l(ind)* (h_f(ind,t)*n_f(ind,t)*(1-vbar_f(ind,t)))**rho(ind) + (1-alphap_f.l(ind))*vv_f(ind,t)**rho(ind) )**(1/rho(ind)-1)*(h_f(ind,t)*n_f(ind,t)*(1-vbar_f(ind,t)))**(rho(ind)-1);
eqn_f_v_f(ind,t).. f_v_f(ind,t) =e= (1-alphap_f.l(ind))*gammay0_f.l(ind)*( alphap_f.l(ind)* (h_f(ind,t)*n_f(ind,t)*(1-vbar_f(ind,t)))**rho(ind) + (1-alphap_f.l(ind))*vv_f(ind,t)**rho(ind) )**(1/rho(ind)-1)*(vv_f(ind,t))**(rho(ind)-1);


* Intermediate input demand

eqn_cost_df(ind,ind2,t).. cost_df(ind,ind2,t) =e= gammadf(ind,ind2)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadf_d(ind,ind2)**sig_df(ind))*((p(ind,t)+mu_e(ind,ind2)*p_e(ind,ind2,t))**(1-sig_df(ind))) + (alphadf_f(ind,ind2)**sig_df(ind))*(((p_f(ind,t)/exch(t))+mu_e(ind,ind2)*p_e(ind,ind2,t)+tar_i2(ind)*p_e(ind,ind2,t))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_id(ind,ind2,t).. io_id(ind,ind2,t) =e= ((gammadf(ind,ind2)*alphadf_d(ind,ind2))**sig_df(ind)) * ((p(ind,t)+mu_e(ind,ind2)*p_e(ind,ind2,t))/cost_df(ind,ind2,t))**(-sig_df(ind));
eqn_io_if(ind,ind2,t).. io_if(ind,ind2,t)  =e=  ((gammadf(ind,ind2)*alphadf_f(ind,ind2))**sig_df(ind)) * (((p_f(ind,t)/exch(t))+mu_e(ind,ind2)*p_e(ind,ind2,t)+tar_i2(ind)*p_e(ind,ind2,t))/cost_df(ind,ind2,t))**(-sig_df(ind));
eqn_cost_e(ind,t).. cost_e(ind,t) =e= gammae(ind)**(sig_e(ind)/(1-sig_e(ind)))*( sum(ie, (alphae(ie,ind)**sig_e(ind))*(cost_df(ie,ind,t))**(1-sig_e(ind))) )**(1/(1-sig_e(ind)));
eqn_io_ie(ie,ind,t).. io_ie(ie,ind,t) =e= ((gammae(ind)*alphae(ie,ind))**sig_e(ind)) * (cost_df(ie,ind,t)/cost_e(ind,t))**(-sig_e(ind));
eqn_cost_m(ind,t).. cost_m(ind,t) =e= gammam(ind)**(sig_m(ind)/(1-sig_m(ind)))*( sum(im, (alpham(im,ind)**sig_m(ind))*(cost_df(im,ind,t))**(1-sig_m(ind))) )**(1/(1-sig_m(ind)));
eqn_io_im(im,ind,t).. io_im(im,ind,t) =e= ((gammam(ind)*alpham(im,ind))**sig_m(ind)) * (cost_df(im,ind,t)/cost_m(ind,t))**(-sig_m(ind));
eqn_cost_v(ind,t).. cost_v(ind,t) =e= gammav(ind,t)**(sig_v(ind)/(1-sig_v(ind)))*( (alphav_e(ind)**sig_v(ind))*((cost_e(ind,t))**(1-sig_v(ind))) + (alphav_m(ind)**sig_v(ind))*((cost_m(ind,t))**(1-sig_v(ind))) )**(1/(1-sig_v(ind)));
eqn_io_ev(ind,t).. io_ev(ind,t) =e= ((gammav(ind,t)*alphav_e(ind))**sig_v(ind)) * (cost_e(ind,t)/cost_v(ind,t))**(-sig_v(ind));
eqn_io_mv(ind,t).. io_mv(ind,t) =e= ((gammav(ind,t)*alphav_m(ind))**sig_v(ind)) * (cost_m(ind,t)/cost_v(ind,t))**(-sig_v(ind));
eqn_firm_iod_e(ie,ind,t).. iod(ie,ind,t) =e= io_id(ie,ind,t)*io_ie(ie,ind,t)*io_ev(ind,t)*vv(ind,t);
eqn_firm_iod_m(im,ind,t).. iod(im,ind,t) =e= io_id(im,ind,t)*io_im(im,ind,t)*io_mv(ind,t)*vv(ind,t);
eqn_firm_iof_e(ie,ind,t).. iof(ie,ind,t) =e= io_if(ie,ind,t)*io_ie(ie,ind,t)*io_ev(ind,t)*vv(ind,t);
eqn_firm_iof_m(im,ind,t).. iof(im,ind,t) =e= io_if(im,ind,t)*io_im(im,ind,t)*io_mv(ind,t)*vv(ind,t);


eqn_cost_df_f(ind,ind2,t).. cost_df_f(ind,ind2,t) =e= gammadf_f(ind,ind2)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadf_d_f(ind,ind2)**sig_df(ind))*((p_f(ind,t))**(1-sig_df(ind))) + (alphadf_f_f(ind,ind2)**sig_df(ind))*(((p(ind,t)*exch(t)))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_id_f(ind,ind2,t).. io_id_f(ind,ind2,t) =e= ((gammadf_f(ind,ind2)*alphadf_d_f(ind,ind2))**sig_df(ind)) * ((p_f(ind,t))/cost_df_f(ind,ind2,t))**(-sig_df(ind));
eqn_io_if_f(ind,ind2,t).. io_if_f(ind,ind2,t)  =e=  ((gammadf_f(ind,ind2)*alphadf_f_f(ind,ind2))**sig_df(ind)) * (((p(ind,t)*exch(t)))/cost_df_f(ind,ind2,t))**(-sig_df(ind));
eqn_cost_e_f(ind,t).. cost_e_f(ind,t) =e= gammae_f(ind)**(sig_e(ind)/(1-sig_e(ind)))*( sum(ie, (alphae_f(ie,ind)**sig_e(ind))*(cost_df_f(ie,ind,t))**(1-sig_e(ind))) )**(1/(1-sig_e(ind)));
eqn_io_ie_f(ie,ind,t).. io_ie_f(ie,ind,t) =e= ((gammae_f(ind)*alphae_f(ie,ind))**sig_e(ind)) * (cost_df_f(ie,ind,t)/cost_e_f(ind,t))**(-sig_e(ind));
eqn_cost_m_f(ind,t).. cost_m_f(ind,t) =e= gammam_f(ind)**(sig_m(ind)/(1-sig_m(ind)))*( sum(im, (alpham_f(im,ind)**sig_m(ind))*(cost_df_f(im,ind,t))**(1-sig_m(ind))) )**(1/(1-sig_m(ind)));
eqn_io_im_f(im,ind,t).. io_im_f(im,ind,t) =e= ((gammam_f(ind)*alpham_f(im,ind))**sig_m(ind)) * (cost_df_f(im,ind,t)/cost_m_f(ind,t))**(-sig_m(ind));
eqn_cost_v_f(ind,t).. cost_v_f(ind,t) =e= gammav_f(ind)**(sig_v(ind)/(1-sig_v(ind)))*( (alphav_e_f(ind)**sig_v(ind))*((cost_e_f(ind,t))**(1-sig_v(ind))) + (alphav_m_f(ind)**sig_v(ind))*((cost_m_f(ind,t))**(1-sig_v(ind))) )**(1/(1-sig_v(ind)));
eqn_io_ev_f(ind,t).. io_ev_f(ind,t) =e= ((gammav_f(ind)*alphav_e_f(ind))**sig_v(ind)) * (cost_e_f(ind,t)/cost_v_f(ind,t))**(-sig_v(ind));
eqn_io_mv_f(ind,t).. io_mv_f(ind,t) =e= ((gammav_f(ind)*alphav_m_f(ind))**sig_v(ind)) * (cost_m_f(ind,t)/cost_v_f(ind,t))**(-sig_v(ind));
eqn_firm_iod_e_f(ie,ind,t).. iod_f(ie,ind,t) =e= io_id_f(ie,ind,t)*io_ie_f(ie,ind,t)*io_ev_f(ind,t)*vv_f(ind,t);
eqn_firm_iod_m_f(im,ind,t).. iod_f(im,ind,t) =e= io_id_f(im,ind,t)*io_im_f(im,ind,t)*io_mv_f(ind,t)*vv_f(ind,t);
eqn_firm_iof_e_f(ie,ind,t).. iof_f(ie,ind,t) =e= io_if_f(ie,ind,t)*io_ie_f(ie,ind,t)*io_ev_f(ind,t)*vv_f(ind,t);
eqn_firm_iof_m_f(im,ind,t).. iof_f(im,ind,t) =e= io_if_f(im,ind,t)*io_im_f(im,ind,t)*io_mv_f(ind,t)*vv_f(ind,t);


* Output and profits
eqn_y(ind,t).. y(ind,t) =e= gammay(ind,t)*(alphap.l(ind)*(h(ind,t)*n(ind,t)*(1-vbar(ind,t)))**rho(ind) + (1-alphap.l(ind))*vv(ind,t)**rho(ind))**(1/rho(ind));
eqn_prof(ind,t).. prof(ind,t) =e= (p(ind,t)*(1+sub(ind,t)))*y(ind,t) - (1+tau_p0)*w(ind,t)*n(ind,t)*h(ind,t) - cost_v(ind,t)*vv(ind,t) ;
eqn_fire(ind,t).. fire(ind,t) =e= -j_n(ind,t)/cost_fire;


eqn_e(ind,t).. e(ind,t) =e=  sum(ie,mu_e(ie,ind)*(iod(ie,ind,t)+iof(ie,ind,t))) + sum(secondary,sum(oilgas,mu_e(oilgas,secondary)*f_y0(secondary)*iof(secondary,ind,t)));
eqn_etot(t).. etot(t) =e= sum(ind,e(ind,t)) - sum(oilgas,sum(secondary,((iod(oilgas,secondary,t)+iof(oilgas,secondary,t))/y(secondary,t))*mu_e(oilgas,secondary)*exports(secondary,t))) + sum(oilgas,sum(secondary,f_y0(secondary)*mu_e(oilgas,secondary)*(cf(secondary,t)+gf(secondary,t))));

eqn_y_f(ind,t).. y_f(ind,t) =e= gammay0_f.l(ind)*(alphap_f.l(ind)*(h_f(ind,t)*n_f(ind,t)*(1-vbar_f(ind,t)))**rho(ind) + (1-alphap_f.l(ind))*vv_f(ind,t)**rho(ind))**(1/rho(ind));
eqn_prof_f(ind,t).. prof_f(ind,t) =e= (p_f(ind,t))*y_f(ind,t) - (1+tau_p0)*w_f(ind,t)*n_f(ind,t)*h_f(ind,t) - cost_v_f(ind,t)*vv_f(ind,t) ;
eqn_fire_f(ind,t).. fire_f(ind,t) =e= -j_n_f(ind,t)/cost_fire;

** Government

eqn_foc_vbarg(t)$(not tlast(t)).. ((lambdag(t))*f_lg(t)) =e= m(t)*qg(t)*(-cg_n(t+1));
eqn_foc_vbarg_tc(tlast).. ((lambdag(tlast))*f_lg(tlast)) =e= m(tlast)*qg(tlast)*(-cg_n_ss_ct);
eqn_foc_ng(t)$(not tlast(t)).. (-cg_n(t)) =e= lambdag(t)*hg(t)*f_lg(t) - (1+tau_p0)*wg(t)*hg(t) + (1-pig)*m(t)*(-cg_n(t+1));
eqn_foc_ng_tc(tlast).. (-cg_n(tlast)) =e= lambdag(tlast)*hg(tlast)*f_lg(tlast) - (1+tau_p0)*wg(tlast)*hg(tlast) + (1-pig)*m(tlast)*(-cg_n_ss_ct);
eqn_foc_vg(t).. lambdag(t)*f_vg(t) =e=  cost_vg(t);
eqn_f_lg(t).. f_lg(t) =e= alphapg.l*gammayg0.l*( alphapg.l* (hg(t)*ng(t)*(1-vbarg(t)))**rhog + (1-alphapg.l)*vvg(t)**rhog )**(1/rhog-1)*(hg(t)*ng(t)*(1-vbarg(t)))**(rhog-1);
eqn_f_vg(t).. f_vg(t) =e= (1-alphapg.l)*gammayg0.l*( alphapg.l* (hg(t)*ng(t)*(1-vbarg(t)))**rhog + (1-alphapg.l)*vvg(t)**rhog )**(1/rhog-1)*(vvg(t))**(rhog-1);

eqn_cost_dfg(ind,t).. cost_dfg(ind,t) =e= gammadfg(ind)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadfg_d(ind)**sig_df(ind))*((p(ind,t))**(1-sig_df(ind))) + (alphadfg_f(ind)**sig_df(ind))*(((p_f(ind,t)/exch(t)))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_idg(ind,t).. io_idg(ind,t) =e= ((gammadfg(ind)*alphadfg_d(ind))**sig_df(ind)) * ((p(ind,t))/cost_dfg(ind,t))**(-sig_df(ind));
eqn_io_ifg(ind,t).. io_ifg(ind,t)  =e=  ((gammadfg(ind)*alphadfg_f(ind))**sig_df(ind)) * (((p_f(ind,t)/exch(t)))/cost_dfg(ind,t))**(-sig_df(ind));
eqn_cost_eg(t).. cost_eg(t) =e= gammaeg**(sig_eg/(1-sig_eg))*( sum(ie, (alphaeg(ie)**sig_eg)*(cost_dfg(ie,t))**(1-sig_eg)) )**(1/(1-sig_eg));
eqn_io_ieg(ie,t).. io_ieg(ie,t) =e= ((gammaeg*alphaeg(ie))**sig_eg) * ((cost_dfg(ie,t))/cost_eg(t))**(-sig_eg);
eqn_cost_mg(t).. cost_mg(t) =e= gammamg**(sig_mg/(1-sig_mg))*( sum(im, (alphamg(im)**sig_mg)*(cost_dfg(im,t))**(1-sig_mg)) )**(1/(1-sig_mg));
eqn_io_img(im,t).. io_img(im,t) =e= ((gammamg*alphamg(im))**sig_mg) * (cost_dfg(im,t)/cost_mg(t))**(-sig_mg);
eqn_cost_vg(t).. cost_vg(t) =e= gammavg**(sig_vg/(1-sig_vg))*( (alphavg_e**sig_vg)*((cost_eg(t))**(1-sig_vg)) + (alphavg_m**sig_vg)*((cost_mg(t))**(1-sig_vg)) )**(1/(1-sig_vg));
eqn_io_evg(t).. io_evg(t) =e= ((gammavg*alphavg_e)**sig_vg) * (cost_eg(t)/cost_vg(t))**(-sig_vg);
eqn_io_mvg(t).. io_mvg(t) =e= ((gammavg*alphavg_m)**sig_vg) * (cost_mg(t)/cost_vg(t))**(-sig_vg);
eqn_gd_e(ie,t).. gd(ie,t) =e= vvg(t)*io_evg(t)*io_ieg(ie,t)*io_idg(ie,t);
eqn_gd_m(im,t).. gd(im,t) =e= vvg(t)*io_mvg(t)*io_img(im,t)*io_idg(im,t);
eqn_gf_e(ie,t).. gf(ie,t) =e= vvg(t)*io_evg(t)*io_ieg(ie,t)*io_ifg(ie,t);
eqn_gf_m(im,t).. gf(im,t) =e= vvg(t)*io_mvg(t)*io_img(im,t)*io_ifg(im,t);




eqn_foc_vbarg_f(t)$(not tlast(t)).. ((lambdag_f(t))*f_lg_f(t)) =e= m_f(t)*qg_f(t)*(-cg_n_f(t+1));
eqn_foc_vbarg_f_tc(tlast).. vbarg_f(tlast) =e= vbarg_f_ss_ct;
eqn_foc_ng_f(t)$(not tlast(t)).. (-cg_n_f(t)) =e= lambdag_f(t)*hg_f(t)*f_lg_f(t) - (1+tau_p0)*wg_f(t)*hg_f(t) + (1-pig_f)*m_f(t)*(-cg_n_f(t+1));
eqn_foc_ng_f_tc(tlast).. (-cg_n_f(tlast)) =e= lambdag_f(tlast)*hg_f(tlast)*f_lg_f(tlast) - (1+tau_p0)*wg_f(tlast)*hg_f(tlast) + (1-pig_f)*m_f(tlast)*(-cg_n_f_ss_ct);
eqn_foc_vg_f(t).. lambdag_f(t)*f_vg_f(t) =e=  cost_vg_f(t);
eqn_f_lg_f(t).. f_lg_f(t) =e= alphapg_f.l*gammayg0_f.l*( alphapg_f.l* (hg_f(t)*ng_f(t)*(1-vbarg_f(t)))**rhog + (1-alphapg_f.l)*vvg_f(t)**rhog )**(1/rhog-1)*(hg_f(t)*ng_f(t)*(1-vbarg_f(t)))**(rhog-1);
eqn_f_vg_f(t).. f_vg_f(t) =e= (1-alphapg_f.l)*gammayg0_f.l*( alphapg_f.l* (hg_f(t)*ng_f(t)*(1-vbarg_f(t)))**rhog + (1-alphapg_f.l)*vvg_f(t)**rhog )**(1/rhog-1)*(vvg_f(t))**(rhog-1);



eqn_cost_dfg_f(ind,t).. cost_dfg_f(ind,t) =e= gammadfg_f(ind)**(sig_df(ind)/(1-sig_df(ind)))*( (alphadfg_d_f(ind)**sig_df(ind))*((p_f(ind,t))**(1-sig_df(ind))) + (alphadfg_f_f(ind)**sig_df(ind))*(((p(ind,t)*exch(t)))**(1-sig_df(ind))) )**(1/(1-sig_df(ind)));
eqn_io_idg_f(ind,t).. io_idg_f(ind,t) =e= ((gammadfg_f(ind)*alphadfg_d_f(ind))**sig_df(ind)) * ((p_f(ind,t))/cost_dfg_f(ind,t))**(-sig_df(ind));
eqn_io_ifg_f(ind,t).. io_ifg_f(ind,t)  =e=  ((gammadfg_f(ind)*alphadfg_f_f(ind))**sig_df(ind)) * (((p(ind,t)*exch(t)))/cost_dfg_f(ind,t))**(-sig_df(ind));
eqn_cost_eg_f(t).. cost_eg_f(t) =e= gammaeg_f**(sig_eg/(1-sig_eg))*( sum(ie, (alphaeg_f(ie)**sig_eg)*(cost_dfg_f(ie,t))**(1-sig_eg)) )**(1/(1-sig_eg));
eqn_io_ieg_f(ie,t).. io_ieg_f(ie,t) =e= ((gammaeg_f*alphaeg_f(ie))**sig_eg) * ((cost_dfg_f(ie,t))/cost_eg_f(t))**(-sig_eg);
eqn_cost_mg_f(t).. cost_mg_f(t) =e= gammamg_f**(sig_mg/(1-sig_mg))*( sum(im, (alphamg_f(im)**sig_mg)*(cost_dfg_f(im,t))**(1-sig_mg)) )**(1/(1-sig_mg));
eqn_io_img_f(im,t).. io_img_f(im,t) =e= ((gammamg_f*alphamg_f(im))**sig_mg) * (cost_dfg_f(im,t)/cost_mg_f(t))**(-sig_mg);
eqn_cost_vg_f(t).. cost_vg_f(t) =e= gammavg_f**(sig_vg/(1-sig_vg))*( (alphavg_e_f**sig_vg)*((cost_eg_f(t))**(1-sig_vg)) + (alphavg_m_f**sig_vg)*((cost_mg_f(t))**(1-sig_vg)) )**(1/(1-sig_vg));
eqn_io_evg_f(t).. io_evg_f(t) =e= ((gammavg_f*alphavg_e_f)**sig_vg) * (cost_eg_f(t)/cost_vg_f(t))**(-sig_vg);
eqn_io_mvg_f(t).. io_mvg_f(t) =e= ((gammavg_f*alphavg_m_f)**sig_vg) * (cost_mg_f(t)/cost_vg_f(t))**(-sig_vg);
eqn_gd_f_e(ie,t).. gd_f(ie,t) =e= vvg_f(t)*io_evg_f(t)*io_ieg_f(ie,t)*io_idg_f(ie,t);
eqn_gd_f_m(im,t).. gd_f(im,t) =e= vvg_f(t)*io_mvg_f(t)*io_img_f(im,t)*io_idg_f(im,t);
eqn_gf_f_e(ie,t).. gf_f(ie,t) =e= vvg_f(t)*io_evg_f(t)*io_ieg_f(ie,t)*io_ifg_f(ie,t);
eqn_gf_f_m(im,t).. gf_f(im,t) =e= vvg_f(t)*io_mvg_f(t)*io_img_f(im,t)*io_ifg_f(im,t);

eqn_sub(ind,t).. p(ind,t)*sub(ind,t) =e= sum(ie,p_e(ie,ind,t)*mu_e(ie,ind)*(iod(ie,ind,t)+iof(ie,ind,t)) + tar_i2(ie)*p_e(ie,ind,t)*iof(ie,ind,t)  )  / y(ind,t);

eqn_grev(t).. grev(t) =e= ( (tau_l+tau_p0)*(sum(ind,n(ind,t)*w(ind,t)*h(ind,t)) + ng(t)*wg(t)*hg(t)) + sum(ie,sum(ind,p_e(ie,ind,t)*mu_e(ie,ind)*(iod(ie,ind,t)+iof(ie,ind,t))) ) - sum(ind,p(ind,t)*sub(ind,t)*y(ind,t)) + sum(ind,tar_i2(ind)*sum(ind2,p_e(ind,ind2,t)*iof(ind,ind2,t)))  + sum(ind,tar_i2(ind)*p_e_c(ind,t)*cf(ind,t))    )/p_cbar(t);

eqn_tlump(t).. tlump(t) =e= ( grev(t)*p_cbar(t) - (1-ntot(t))*p_cbar(t)*b0.l - cost_vg(t)*vvg(t) -(1+tau_p0)*ng(t)*wg(t)*hg(t))/p_cbar(t);

eqn_vlump(t)$(not tlast(t)).. vlump(t) =e= tlump(t) + m(t)*vlump(t+1);
eqn_vlump_tc(tlast).. vlump(tlast) =e= tlump(tlast) + m(tlast)*vlump_ss_ct;


eqn_grev_f(t).. grev_f(t) =e= ( (tau_l0+tau_p0)*(sum(ind,n_f(ind,t)*w_f(ind,t)*h_f(ind,t)) + ng_f(t)*wg_f(t)*hg_f(t)) )/p_cbar_f(t);
eqn_tlump_f(t).. tlump_f(t) =e= ( grev_f(t)*p_cbar_f(t) - (ratiof-ntot_f(t))*p_cbar_f(t)*b0_f.l -  cost_vg_f(t)*vvg_f(t) -(1+tau_p0)*ng_f(t)*wg_f(t)*hg_f(t))/p_cbar_f(t);


** Labor Market


eqn_phi_i(ind,t).. phi_i(ind,t) =e= mu.l(ind)*(theta_i(ind,t)*thetatot(t)**(-gamma));
eqn_q(ind,t).. q(ind,t) =e= mu.l(ind)*(thetatot(t)**(-gamma));
eqn_theta_i(ind,t).. theta_i(ind,t) =e= (vbar(ind,t)*n(ind,t)*h(ind,t))/(1-ntot(t));
eqn_n(ind,t).. n(ind,t) =e= n0(ind)$tfirst(t) + (1-pi(ind))*(n(ind,t-1)) + q(ind,t-1)*vbar(ind,t-1)*h(ind,t-1)*(n(ind,t-1)) - fire(ind,t);

eqn_phi_g(t).. phi_g(t) =e= mug.l*(theta_g(t)*thetatot(t)**(-gamma) );
eqn_qg(t).. qg(t) =e= mug.l*(thetatot(t)**(-gamma));
eqn_theta_g(t).. theta_g(t) =e= hg(t)*vbarg(t)*ng(t)/(1-ntot(t));
eqn_ng(t).. ng(t) =e= ng0$tfirst(t) + (1-pig)*(ng(t-1)) + qg(t-1)*vbarg(t-1)*hg(t-1)*(ng(t-1));


eqn_thetatot(t).. thetatot(t) =e= sum(ind,theta_i(ind,t)) + theta_g(t);
eqn_ntot(t).. ntot(t) =e= sum(ind,n(ind,t)) + ng(t);

eqn_phi_f(ind,t).. phi_f(ind,t) =e= mu_f.l(ind)*theta_f(ind,t)*thetatot_f(t)**(-gamma);
eqn_q_f(ind,t).. q_f(ind,t) =e= mu_f.l(ind)*thetatot_f(t)**(-gamma);
eqn_theta_f(ind,t).. theta_f(ind,t) =e= vbar_f(ind,t)*h_f(ind,t)*n_f(ind,t)/(ratiof-ntot_f(t));
eqn_n_f(ind,t).. n_f(ind,t) =e= n0_f(ind)$tfirst(t) + (1-pi_f(ind))*(n_f(ind,t-1)) + q_f(ind,t-1)*vbar_f(ind,t-1)*h_f(ind,t-1)*(n_f(ind,t-1));


eqn_phig_f(t).. phig_f(t) =e= mug_f.l*thetag_f(t)*thetatot_f(t)**(-gamma);
eqn_qg_f(t).. qg_f(t) =e= mug_f.l*thetatot_f(t)**(-gamma);
eqn_thetag_f(t).. thetag_f(t) =e= vbarg_f(t)*hg_f(t)*ng_f(t)/(ratiof-ntot_f(t));
eqn_ng_f(t).. ng_f(t) =e= ng0_f$tfirst(t) + (1-pig_f)*(ng_f(t-1)) + qg_f(t-1)*vbarg_f(t-1)*hg_f(t-1)*(ng_f(t-1));

eqn_thetatot_f(t).. thetatot_f(t) =e= (sum(ind,vbar_f(ind,t)*h_f(ind,t)*n_f(ind,t)) + vbarg_f(t)*hg_f(t)*ng_f(t))/(ratiof-ntot_f(t));
eqn_ntot_f(t).. ntot_f(t) =e= sum(ind,n_f(ind,t)) + ng_f(t);


** Trade

eqn_imports(ind,t).. imports(ind,t) =e= sum(ind2,iof(ind,ind2,t)) + cf(ind,t) + gf(ind,t);
eqn_exports(ind,t).. exports(ind,t) =e= sum(ind2,iof_f(ind,ind2,t)) + cf_f(ind,t) + gf_f(ind,t);
eqn_tbal(t).. sum(ind,p(ind,t)*exports(ind,t) - (p_f(ind,t)/exch(t))*imports(ind,t)) =e= 0;

** Market Clearing

eqn_mc(ind,t).. y(ind,t) =g= cd(ind,t) + gd(ind,t) +  exports(ind,t) + sum(ind2,iod(ind,ind2,t));
eqn_mc_f(ind,t).. y_f(ind,t) =g= cd_f(ind,t) + gd_f(ind,t) +  imports(ind,t) + sum(ind2,iod_f(ind,ind2,t));

eqn_yg(t).. gammayg0.l*( alphapg.l*(hg(t)*ng(t)*(1-vbarg(t)))**rhog + (1-alphapg.l)*vvg(t)**rhog)**(1/rhog) =g= yg0;
eqn_yg_f(t).. gammayg0_f.l*( alphapg_f.l*(hg_f(t)*ng_f(t)*(1-vbarg_f(t)))**rhog + (1-alphapg_f.l)*vvg_f(t)**rhog)**(1/rhog) =g= yg0_f;

** Revenue Neutral

eqn_vlump_d.. vlump_d =e= vlump('t1') - vlump_ss;
eqn_rn.. vlump_d =e= 0;


* Initialize

p.l(ind,t) = p_ss_ct.l(ind);
p.fx('i22',t) = 1;
p_c.l(ind,t) = p_c_ss_ct.l(ind);
p_cbar.l(t) = p_cbar_ss_ct.l;
exch.l(t) = exch_ss_ct.l;

sub.l(ind,t) = sub_ss_ct.l(ind);

p_f.l(ind,t) = p_f_ss_ct.l(ind);
p_f.fx('i22',t) = 1;
p_c_f.l(ind,t) = p_c_f_ss_ct.l(ind);
p_cbar_f.l(t) = p_cbar_ss_ct.l;

lambda.l(t) = lambda_ss_ct.l;
lambda_f.l(t) = lambda_f_ss_ct.l;

lambdag.l(t) = lambdag_ss_ct.l;
lambdag_f.l(t) = lambdag_f_ss_ct.l;


cbar.l(t) = cbar_ss_ct.l;
c.l(ind,t) = c_ss_ct.l(ind);
cd.l(ind,t) = cd_ss_ct.l(ind);
cf.l(ind,t) = cf_ss_ct.l(ind);
m.l(t) = beta;
v_n.l(ind,t) = v_n_ss_ct.l(ind);
v_ng.l(t) = v_ng_ss_ct.l;
phibar.l(t) = phibar_ss_ct.l;


cbar_f.l(t) = cbar_f_ss_ct.l;
c_f.l(ind,t) = c_f_ss_ct.l(ind);
cd_f.l(ind,t) = cd_f_ss_ct.l(ind);
cf_f.l(ind,t) = cf_f_ss_ct.l(ind);
m_f.l(t) = beta;
v_n_f.l(ind,t) = v_n_f_ss_ct.l(ind);
v_ng_f.l(t) = v_ng_f_ss_ct.l;
phibar_f.l(t) = phibar_f_ss_ct.l;

w.l(ind,t) = w_ss_ct.l(ind);
h.l(ind,t) = h_ss_ct.l(ind);
w_f.l(ind,t) = w_f_ss_ct.l(ind);
h_f.l(ind,t) = h_f_ss_ct.l(ind);

wg.l(t) = wg_ss_ct.l;
hg.l(t) = hg_ss_ct.l;
wg_f.l(t) = wg_f_ss_ct.l;
hg_f.l(t) = hg_f_ss_ct.l;

vbar.l(ind,t) = vbar_ss_ct.l(ind);
j_n.l(ind,t) = j_n_ss_ct.l(ind);
f_l.l(ind,t) = f_l_ss_ct.l(ind);
f_v.l(ind,t) = f_v_ss_ct.l(ind);
vv.l(ind,t) = vv_ss_ct.l(ind);
io_id.l(ind,ind2,t) = io_id_ss_ct.l(ind,ind2);
io_if.l(ind,ind2,t) = io_if_ss_ct.l(ind,ind2);
cost_df.l(ind,ind2,t) = cost_df_ss_ct.l(ind,ind2);
cost_e.l(ind,t) = cost_e_ss_ct.l(ind);
io_ie.l(ie,ind,t) = io_ie_ss_ct.l(ie,ind);
cost_m.l(ind,t) = cost_m_ss_ct.l(ind);
io_im.l(im,ind,t) = io_im_ss_ct.l(im,ind);
cost_v.l(ind,t) = cost_v_ss_ct.l(ind);
io_ev.l(ind,t) = io_ev_ss_ct.l(ind);
io_mv.l(ind,t) = io_mv_ss_ct.l(ind);
iod.l(ind,ind2,t) = iod_ss_ct.l(ind,ind2);
iof.l(ind,ind2,t) = iof_ss_ct.l(ind,ind2);
y.l(ind,t) = y_ss_ct.l(ind);
prof.l(ind,t) = prof_ss_ct.l(ind);
fire.l(ind,t) = 0;
e.l(ind,t) = e_ss_ct.l(ind);
etot.l(t) = etot_ss_ct.l;

vbar_f.l(ind,t) = vbar_f_ss_ct.l(ind);
j_n_f.l(ind,t) = j_n_f_ss_ct.l(ind);
f_l_f.l(ind,t) = f_l_f_ss_ct.l(ind);
f_v_f.l(ind,t) = f_v_f_ss_ct.l(ind);
vv_f.l(ind,t) = vv_f_ss_ct.l(ind);
io_id_f.l(ind,ind2,t) = io_id_f_ss_ct.l(ind,ind2);
io_if_f.l(ind,ind2,t) = io_if_f_ss_ct.l(ind,ind2);
cost_df_f.l(ind,ind2,t) = cost_df_f_ss_ct.l(ind,ind2);
cost_e_f.l(ind,t) = cost_e_f_ss_ct.l(ind);
io_ie_f.l(ie,ind,t) = io_ie_f_ss_ct.l(ie,ind);
cost_m_f.l(ind,t) = cost_m_f_ss_ct.l(ind);
io_im_f.l(im,ind,t) = io_im_f_ss_ct.l(im,ind);
cost_v_f.l(ind,t) = cost_v_f_ss_ct.l(ind);
io_ev_f.l(ind,t) = io_ev_f_ss_ct.l(ind);
io_mv_f.l(ind,t) = io_mv_f_ss_ct.l(ind);
iod_f.l(ind,ind2,t) = iod_f_ss_ct.l(ind,ind2);
iof_f.l(ind,ind2,t) = iof_f_ss_ct.l(ind,ind2);
y_f.l(ind,t) = y_f_ss_ct.l(ind);
prof_f.l(ind,t) = prof_f_ss_ct.l(ind);
fire_f.l(ind,t) = 0;

vbarg.l(t) = vbarg_ss_ct.l;
cg_n.l(t) = cg_n_ss_ct.l;
f_lg.l(t) = f_lg_ss_ct.l;
f_vg.l(t) = f_vg_ss_ct.l;
vvg.l(t) = vvg_ss_ct.l;
io_idg.l(ind,t) = io_idg_ss_ct.l(ind);
io_ifg.l(ind,t) = io_ifg_ss_ct.l(ind);
cost_dfg.l(ind,t) = cost_dfg_ss_ct.l(ind);
cost_eg.l(t) = cost_eg_ss_ct.l;
io_ieg.l(ie,t) = io_ieg_ss_ct.l(ie);
cost_mg.l(t) = cost_mg_ss_ct.l;
io_img.l(im,t) = io_img_ss_ct.l(im);
cost_vg.l(t) = cost_vg_ss_ct.l;
io_evg.l(t) = io_evg_ss_ct.l;
io_mvg.l(t) = io_mvg_ss_ct.l;
gd.l(ind,t) = gd_ss_ct.l(ind);
gf.l(ind,t) = gf_ss_ct.l(ind);


vbarg_f.l(t) = vbarg_f_ss_ct.l;
cg_n_f.l(t) = cg_n_f_ss_ct.l;
f_lg_f.l(t) = f_lg_f_ss_ct.l;
f_vg_f.l(t) = f_vg_f_ss_ct.l;
vvg_f.l(t) = vvg_f_ss_ct.l;
io_idg_f.l(ind,t) = io_idg_f_ss_ct.l(ind);
io_ifg_f.l(ind,t) = io_ifg_f_ss_ct.l(ind);
cost_dfg_f.l(ind,t) = cost_dfg_f_ss_ct.l(ind);
cost_eg_f.l(t) = cost_eg_f_ss_ct.l;
io_ieg_f.l(ie,t) = io_ieg_f_ss_ct.l(ie);
cost_mg_f.l(t) = cost_mg_f_ss_ct.l;
io_img_f.l(im,t) = io_img_f_ss_ct.l(im);
cost_vg_f.l(t) = cost_vg_f_ss_ct.l;
io_evg_f.l(t) = io_evg_f_ss_ct.l;
io_mvg_f.l(t) = io_mvg_f_ss_ct.l;
gd_f.l(ind,t) = gd_f_ss_ct.l(ind);
gf_f.l(ind,t) = gf_f_ss_ct.l(ind);

phi_i.l(ind,t) = phi_i_ss_ct.l(ind);
q.l(ind,t) = q_ss_ct.l(ind);
theta_i.l(ind,t) = theta_i_ss_ct.l(ind);
n.l(ind,t) = n_ss_ct.l(ind);

phi_g.l(t) = phi_g_ss_ct.l;
qg.l(t) = qg_ss_ct.l;
theta_g.l(t) = theta_g_ss_ct.l;
ng.l(t) = ng_ss_ct.l;

thetatot.l(t) = thetatot_ss_ct.l;
ntot.l(t) = ntot_ss_ct.l;

phi_f.l(ind,t) = phi_f_ss_ct.l(ind);
q_f.l(ind,t) = q_f_ss_ct.l(ind);
theta_f.l(ind,t) = theta_f_ss_ct.l(ind);
n_f.l(ind,t) = n_f_ss_ct.l(ind);
phig_f.l(t) = phig_f_ss_ct.l;
qg_f.l(t) = qg_f_ss_ct.l;
thetag_f.l(t) = thetag_f_ss_ct.l;
ng_f.l(t) = ng_f_Ss_ct.l;
thetatot_f.l(t) = thetatot_f_ss_ct.l;
ntot_f.l(t) = ntot_f_ss_ct.l;

grev.l(t) = grev_ss_ct.l;
tlump.l(t) = tlump_ss_ct.l;
vlump.l(t) = tlump_ss_ct.l + m.l(t)*vlump_ss_ct.l;


grev_f.l(t) = grev_f_ss_ct.l;
tlump_f.l(t) = tlump_f_ss_ct.l;

exports.l(ind,t) = exports_ss_ct.l(ind);
imports.l(ind,t) = imports_ss_ct.l(ind);

fire.lo(ind,t)$(not tlast(t)) = 0;
fire.fx(ind,tlast) = 0;
fire_f.lo(ind,t)$(not tlast(t)) = 0;
fire_f.fx(ind,tlast) = 0;
vbar.lo(ind,t)$(not tlast(t)) = 0;
vbar_f.lo(ind,t)$(not tlast(t)) = 0;
vbarg.lo(t)$(not tlast(t)) = 0;
vbarg_f.lo(t)$(not tlast(t)) = 0;







model hwc_trans_ct /
eqn_p_cbar_ss_ct.p_cbar_ss_ct
eqn_p_c_ss_ct.p_c_ss_ct


eqn_p_cbar_f_ss_ct.p_cbar_f_ss_ct
eqn_p_c_f_ss_ct.p_c_f_ss_ct

eqn_hhfoc_ss_ct.cbar_ss_ct
eqn_bc_ss_ct.lambda_ss_ct
eqn_c_ss_ct.c_ss_ct
eqn_cd_ss_ct.cd_ss_ct
eqn_cf_ss_ct.cf_ss_ct

eqn_v_n_ss_ct.v_n_ss_ct
eqn_v_ng_ss_ct.v_ng_ss_ct
eqn_phibar_ss_ct.phibar_ss_ct

eqn_hhfoc_f_ss_ct.cbar_f_ss_ct
eqn_bc_f_ss_ct.lambda_f_ss_ct
eqn_c_f_ss_ct.c_f_ss_ct
eqn_cd_f_ss_ct.cd_f_ss_ct
eqn_cf_f_ss_ct.cf_f_ss_ct

eqn_nash_ss_ct.w_ss_ct
eqn_intra_ss_ct.h_ss_ct
eqn_nashg_ss_ct.wg_ss_ct
eqn_intrag_ss_ct.hg_ss_ct

eqn_nash_f_ss_ct.w_f_ss_ct
eqn_intra_f_ss_ct.h_f_ss_ct
eqn_nashg_f_ss_ct.wg_f_ss_ct
eqn_intrag_f_ss_ct.hg_f_ss_ct

eqn_foc_vbar_ss_ct.vbar_ss_ct
eqn_foc_v_ss_ct.vv_ss_ct
eqn_foc_n_ss_ct.j_n_ss_ct
eqn_f_l_ss_ct.f_l_ss_ct
eqn_f_v_ss_ct.f_v_ss_ct
eqn_cost_df_ss_ct.cost_df_ss_ct
eqn_io_id_ss_ct.io_id_ss_ct
eqn_io_if_ss_ct.io_if_ss_ct
eqn_cost_e_ss_ct.cost_e_ss_ct
eqn_io_ie_ss_ct.io_ie_ss_ct
eqn_cost_m_ss_ct.cost_m_ss_ct
eqn_io_im_ss_ct.io_im_ss_ct
eqn_cost_v_ss_ct.cost_v_ss_ct
eqn_io_ev_ss_ct.io_ev_ss_ct
eqn_io_mv_ss_ct.io_mv_ss_ct
eqn_firm_iod_e_ss_ct.iod_ss_ct
eqn_firm_iod_m_ss_ct.iod_ss_ct
eqn_firm_iof_e_ss_ct.iof_ss_ct
eqn_firm_iof_m_ss_ct.iof_ss_ct
eqn_y_ss_ct.y_ss_ct
eqn_prof_ss_ct.prof_ss_ct
eqn_e_ss_ct.e_ss_ct
eqn_etot_ss_ct.etot_ss_ct

eqn_foc_vbar_f_ss_ct.vbar_f_ss_ct
eqn_foc_v_f_ss_ct.vv_f_ss_ct
eqn_foc_n_f_ss_ct.j_n_f_ss_ct
eqn_f_l_f_ss_ct.f_l_f_ss_ct
eqn_f_v_f_ss_ct.f_v_f_ss_ct
eqn_cost_df_f_ss_ct.cost_df_f_ss_ct
eqn_io_id_f_ss_ct.io_id_f_ss_ct
eqn_io_if_f_ss_ct.io_if_f_ss_ct
eqn_cost_e_f_ss_ct.cost_e_f_ss_ct
eqn_io_ie_f_ss_ct.io_ie_f_ss_ct
eqn_cost_m_f_ss_ct.cost_m_f_ss_ct
eqn_io_im_f_ss_ct.io_im_f_ss_ct
eqn_cost_v_f_ss_ct.cost_v_f_ss_ct
eqn_io_ev_f_ss_ct.io_ev_f_ss_ct
eqn_io_mv_f_ss_ct.io_mv_f_ss_ct
eqn_firm_iod_e_f_ss_ct.iod_f_ss_ct
eqn_firm_iod_m_f_ss_ct.iod_f_ss_ct
eqn_firm_iof_e_f_ss_ct.iof_f_ss_ct
eqn_firm_iof_m_f_ss_ct.iof_f_ss_ct
eqn_y_f_ss_ct.y_f_ss_ct
eqn_prof_f_ss_ct.prof_f_ss_ct

eqn_foc_vbarg_ss_ct.vbarg_ss_ct
eqn_foc_vg_ss_ct.vvg_ss_ct
eqn_foc_ng_ss_ct.cg_n_ss_ct
eqn_f_lg_ss_ct.f_lg_ss_ct
eqn_f_vg_ss_ct.f_vg_ss_ct
eqn_cost_dfg_ss_ct.cost_dfg_ss_ct
eqn_io_idg_ss_ct.io_idg_ss_ct
eqn_io_ifg_ss_ct.io_ifg_ss_ct
eqn_cost_eg_ss_ct.cost_eg_ss_ct
eqn_io_ieg_ss_ct.io_ieg_ss_ct
eqn_cost_mg_ss_ct.cost_mg_ss_ct
eqn_io_img_ss_ct.io_img_ss_ct
eqn_cost_vg_ss_ct.cost_vg_ss_ct
eqn_io_evg_ss_ct.io_evg_ss_ct
eqn_io_mvg_ss_ct.io_mvg_ss_ct
eqn_gd_e_ss_ct.gd_ss_ct
eqn_gd_m_ss_ct.gd_ss_ct
eqn_gf_e_ss_ct.gf_ss_ct
eqn_gf_m_ss_ct.gf_ss_ct

eqn_foc_vbarg_f_ss_ct.vbarg_f_ss_ct
eqn_foc_vg_f_ss_ct.vvg_f_ss_ct
eqn_foc_ng_f_ss_ct.cg_n_f_ss_ct
eqn_f_lg_f_ss_ct.f_lg_f_ss_ct
eqn_f_vg_f_ss_ct.f_vg_f_ss_ct
eqn_cost_dfg_f_ss_ct.cost_dfg_f_ss_ct
eqn_io_idg_f_ss_ct.io_idg_f_ss_ct
eqn_io_ifg_f_ss_ct.io_ifg_f_ss_ct
eqn_cost_eg_f_ss_ct.cost_eg_f_ss_ct
eqn_io_ieg_f_ss_ct.io_ieg_f_ss_ct
eqn_cost_mg_f_ss_ct.cost_mg_f_ss_ct
eqn_io_img_f_ss_ct.io_img_f_ss_ct
eqn_cost_vg_f_ss_ct.cost_vg_f_ss_ct
eqn_io_evg_f_ss_ct.io_evg_f_ss_ct
eqn_io_mvg_f_ss_ct.io_mvg_f_ss_ct
eqn_gd_f_e_ss_ct.gd_f_ss_ct
eqn_gd_f_m_ss_ct.gd_f_ss_ct
eqn_gf_f_e_ss_ct.gf_f_ss_ct
eqn_gf_f_m_ss_ct.gf_f_ss_ct


eqn_sub_ss_ct.sub_ss_ct

eqn_grev_ss_ct.grev_ss_ct
eqn_tlump_ss_ct.tlump_ss_ct
eqn_vlump_ss_ct.vlump_ss_ct

eqn_grev_f_ss_ct.grev_f_ss_ct
eqn_tlump_f_ss_ct.tlump_f_ss_ct

eqn_phi_i_ss_ct.phi_i_ss_ct
eqn_q_ss_ct.q_ss_ct
eqn_theta_i_ss_ct.theta_i_ss_ct
eqn_n_ss_ct.n_ss_ct

eqn_phi_g_ss_ct.phi_g_ss_ct
eqn_qg_ss_ct.qg_ss_ct
eqn_theta_g_ss_ct.theta_g_ss_ct
eqn_ng_ss_ct.ng_ss_ct

eqn_thetatot_ss_ct.thetatot_ss_ct
eqn_ntot_ss_ct.ntot_ss_ct

eqn_phi_f_ss_ct.phi_f_ss_ct
eqn_q_f_ss_ct.q_f_ss_ct
eqn_theta_f_ss_ct.theta_f_ss_ct
eqn_n_f_ss_ct.n_f_ss_ct
eqn_phig_f_ss_ct.phig_f_ss_ct
eqn_qg_f_ss_ct.qg_f_ss_ct
eqn_thetag_f_ss_ct.thetag_f_ss_ct
eqn_ng_f_ss_ct.ng_f_ss_ct
eqn_thetatot_f_ss_ct.thetatot_f_ss_ct
eqn_ntot_f_ss_ct.ntot_f_ss_ct

eqn_exports_ss_ct.exports_ss_ct
eqn_imports_ss_ct.imports_ss_ct
eqn_tbal_ss_ct.exch_ss_ct

eqn_mc_ss_ct.p_ss_ct
eqn_yg_ss_ct.lambdag_ss_ct
eqn_mc_f_ss_ct.p_f_ss_ct
eqn_yg_f_ss_ct.lambdag_f_ss_ct

eqn_p_cbar.p_cbar
eqn_p_c.p_c
eqn_p_cbar_f.p_cbar_f
eqn_p_c_f.p_c_f

eqn_hhfoc.cbar
eqn_hheuler.m
eqn_hheuler_tc.m
eqn_bc.lambda
eqn_c.c
eqn_cd.cd
eqn_cf.cf
eqn_v_n.v_n
eqn_v_n_tc.v_n
eqn_v_ng.v_ng
eqn_v_ng_tc.v_ng
eqn_phibar.phibar
eqn_phibar_tc.phibar


eqn_hhfoc_f.cbar_f
eqn_hheuler_f.m_f
eqn_hheuler_f_tc.m_f
eqn_bc_f.lambda_f
eqn_c_f.c_f
eqn_cd_f.cd_f
eqn_cf_f.cf_f


eqn_nash.w
eqn_intra.h

eqn_nash_f.w_f
eqn_intra_f.h_f

eqn_nashg.wg
eqn_intrag.hg

eqn_nashg_f.wg_f
eqn_intrag_f.hg_f


eqn_foc_vbar.vbar
eqn_foc_vbar_tc.vbar
eqn_foc_n.j_n
eqn_foc_n_tc.j_n
eqn_foc_v.vv
eqn_f_l.f_l
eqn_f_v.f_v
eqn_cost_df.cost_df
eqn_io_id.io_id
eqn_io_if.io_if
eqn_cost_e.cost_e
eqn_io_ie.io_ie
eqn_cost_m.cost_m
eqn_io_im.io_im
eqn_cost_v.cost_v
eqn_io_ev.io_ev
eqn_io_mv.io_mv
eqn_firm_iod_e.iod
eqn_firm_iod_m.iod
eqn_firm_iof_e.iof
eqn_firm_iof_m.iof
eqn_y.y
eqn_prof.prof
eqn_fire.fire
eqn_e.e
eqn_etot.etot


eqn_foc_vbar_f.vbar_f
eqn_foc_vbar_f_tc.vbar_f
eqn_foc_n_f.j_n_f
eqn_foc_n_f_tc.j_n_f
eqn_foc_v_f.vv_f
eqn_f_l_f.f_l_f
eqn_f_v_f.f_v_f
eqn_cost_df_f.cost_df_f
eqn_io_id_f.io_id_f
eqn_io_if_f.io_if_f
eqn_cost_e_f.cost_e_f
eqn_io_ie_f.io_ie_f
eqn_cost_m_f.cost_m_f
eqn_io_im_f.io_im_f
eqn_cost_v_f.cost_v_f
eqn_io_ev_f.io_ev_f
eqn_io_mv_f.io_mv_f
eqn_firm_iod_e_f.iod_f
eqn_firm_iod_m_f.iod_f
eqn_firm_iof_e_f.iof_f
eqn_firm_iof_m_f.iof_f
eqn_y_f.y_f
eqn_prof_f.prof_f
eqn_fire_f.fire_f

eqn_foc_vbarg.vbarg
eqn_foc_vbarg_tc.vbarg
eqn_foc_ng.cg_n
eqn_foc_ng_tc.cg_n
eqn_foc_vg.vvg
eqn_f_lg.f_lg
eqn_f_vg.f_vg
eqn_cost_dfg.cost_dfg
eqn_io_idg.io_idg
eqn_io_ifg.io_ifg
eqn_cost_eg.cost_eg
eqn_io_ieg.io_ieg
eqn_cost_mg.cost_mg
eqn_io_img.io_img
eqn_cost_vg.cost_vg
eqn_io_evg.io_evg
eqn_io_mvg.io_mvg
eqn_gd_e.gd
eqn_gd_m.gd
eqn_gf_e.gf
eqn_gf_m.gf

eqn_foc_vbarg_f.vbarg_f
eqn_foc_vbarg_f_tc.vbarg_f
eqn_foc_ng_f.cg_n_f
eqn_foc_ng_f_tc.cg_n_f
eqn_foc_vg_f.vvg_f
eqn_f_lg_f.f_lg_f
eqn_f_vg_f.f_vg_f
eqn_cost_dfg_f.cost_dfg_f
eqn_io_idg_f.io_idg_f
eqn_io_ifg_f.io_ifg_f
eqn_cost_eg_f.cost_eg_f
eqn_io_ieg_f.io_ieg_f
eqn_cost_mg_f.cost_mg_f
eqn_io_img_f.io_img_f
eqn_cost_vg_f.cost_vg_f
eqn_io_evg_f.io_evg_f
eqn_io_mvg_f.io_mvg_f
eqn_gd_f_e.gd_f
eqn_gd_f_m.gd_f
eqn_gf_f_e.gf_f
eqn_gf_f_m.gf_f

eqn_phi_i.phi_i
eqn_q.q
eqn_theta_i.theta_i
eqn_n.n

eqn_phi_g.phi_g
eqn_qg.qg
eqn_theta_g.theta_g
eqn_ng.ng

eqn_thetatot.thetatot
eqn_ntot.ntot

eqn_phi_f.phi_f
eqn_q_f.q_f
eqn_theta_f.theta_f
eqn_n_f.n_f
eqn_phig_f.phig_f
eqn_qg_f.qg_f
eqn_thetag_f.thetag_f
eqn_ng_f.ng_f
eqn_thetatot_f.thetatot_f
eqn_ntot_f.ntot_f

eqn_sub.sub

eqn_grev.grev
eqn_tlump.tlump
eqn_vlump.vlump
eqn_vlump_tc.vlump


eqn_grev_f.grev_f
eqn_tlump_f.tlump_f

eqn_exports.exports
eqn_imports.imports
eqn_tbal.exch

eqn_mc.p
eqn_mc_f.p_f
eqn_yg.lambdag
eqn_yg_f.lambdag_f

eqn_vlump_d.vlump_d
eqn_rn.tau_l
/;
